Skip to main content

Sign in a user

Use the useWeb3AuthConnect hook to authenticate a user. Call connectTo with an AUTH_CONNECTION constant and any additional parameters required by the chosen provider.

Import

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

Usage

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

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 })}
/>
<Button
title="Sign in with Apple"
disabled={loading}
onPress={() => connectTo({ authConnection: AUTH_CONNECTION.APPLE })}
/>
{error && <Text style={{ color: 'red' }}>{error.message}</Text>}
</View>
)
}

Parameters

ParameterRequiredDescription
authConnectionYesAuthentication method. Pass an AUTH_CONNECTION.* constant. Replaces the v8 loginProvider field.
authConnectionId?NoDashboard Connection ID for the auth connection. Required when using AUTH_CONNECTION.CUSTOM or when you have multiple connections of the same type and need to target one specifically. Replaces the v8 loginConfig[key].verifier.
groupedAuthConnectionId?NoDashboard Grouped Connection ID when using grouped (aggregate) connections. Connections sharing the same groupedAuthConnectionId produce the same wallet address. Replaces the v8 loginConfig[key].verifierSubIdentifier.
idToken?NoA JWT issued by your authentication provider (Firebase, Auth0, Cognito, and so on). Pass this when using AUTH_CONNECTION.CUSTOM. The token is sent directly to the SDK instead of opening a browser redirect.
extraLoginOptions?NoAdditional OAuth hints passed to the authentication provider. Common fields: login_hint (email), domain (Auth0 domain), verifierIdField (JWT claim to use as the wallet identifier).
redirectUrl?NoOverride the global redirectUrl from web3AuthOptions for this login call only.
mfaLevel?NoOverride the global mfaLevel for this login call only.
curve?NoElliptic curve to use for key generation. Accepts SUPPORTED_KEY_CURVES.SECP256K1 (EVM) or SUPPORTED_KEY_CURVES.ED25519 (Solana). Defaults to the chain namespace.
sessionTime?NoOverride the global session duration (in seconds) for this login session only.
dappShare?NoCustom device share key for MFA-enabled wallets. Required when reconstructing a key with a custom share.
appState?NoArbitrary state string that is returned in the redirect callback. Useful for restoring application state after the OAuth redirect.