For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

useWeb3AuthConnect

Hook to sign a user in. Call connectTo with an AUTH_CONNECTION constant. For OAuth and passwordless connections, the SDK opens the sign-in flow in an in-app browser and returns to your app through redirectUrl. When you pass an idToken, the SDK skips the browser and derives the wallet directly from the token.

Import​

import { useWeb3AuthConnect } from '@web3auth/react-native-sdk'

Usage​

import { AUTH_CONNECTION, useWeb3AuthConnect } from '@web3auth/react-native-sdk'
import { Button, Text, View } from 'react-native'

function LoginView() {
const { connectTo, loading, error } = useWeb3AuthConnect()

return (
<View>
<Button
title={loading ? 'Signing in…' : 'Sign in with Google'}
disabled={loading}
onPress={() => connectTo({ authConnection: AUTH_CONNECTION.GOOGLE })}
/>
{error && <Text>{error.message}</Text>}
</View>
)
}

Return type​

import { type IUseWeb3AuthConnect } from '@web3auth/react-native-sdk'

connectTo​

(params: SdkLoginParams) => Promise<Connection | null>

Starts sign-in with the specified connection. Resolves with the new connection on success. On failure, it resolves with null and sets error instead of throwing, so check the return value or error after you await it.

loading​

boolean

true while sign-in is in progress.

error​

Web3authRNError | null

Error from the most recent connectTo call, or null.

isConnected​

boolean

true when the user has an active session. Mirrors useWeb3Auth().isConnected.

connectTo parameters​

ParameterRequiredDescription
authConnectionYesAuthentication method. Pass an AUTH_CONNECTION.* constant.
authConnectionId?NoConnection ID from the dashboard. Required for AUTH_CONNECTION.CUSTOM and for grouped connections. Also use it to target a specific connection when you have several of the same type.
groupedAuthConnectionId?NoGrouped connection ID from the dashboard. Connections in the same group produce the same wallet for the same user.
idToken?NoJWT from your own auth provider. When set, the SDK skips the in-app browser and derives the wallet from the token directly. Requires authConnectionId. See Custom authentication.
extraLoginOptions?NoExtra OAuth parameters for browser-based sign-in, for example login_hint (email or phone number for passwordless), domain (Auth0 domain), and verifierIdField (JWT claim used as the user ID).
mfaLevel?NoWhen to show the MFA setup screen: 'optional', 'mandatory', or 'none' (MFA_LEVELS.OPTIONAL, MFA_LEVELS.MANDATORY, MFA_LEVELS.NONE).
curve?NoKey curve: SUPPORTED_KEY_CURVES.SECP256K1 or SUPPORTED_KEY_CURVES.ED25519.
dappShare?NoDapp share for MFA-enabled custom connections. The SDK stores and reuses the dapp share automatically; see Dapp share.
appState?NoCustom state string returned in userInfo.appState after sign-in.
dappUrl?NoCustom redirect URL for the manage MFA flow.