useWeb3AuthUser
Hook to read the signed-in user's profile and MFA status. The hook loads userInfo automatically
when the user connects and clears it when the user disconnects.
Import
import { useWeb3AuthUser } from '@web3auth/react-native-sdk'
Usage
import { useWeb3AuthUser } from '@web3auth/react-native-sdk'
import { Image, Text, View } from 'react-native'
function ProfileView() {
const { userInfo, isMFAEnabled } = useWeb3AuthUser()
if (!userInfo) return null
return (
<View>
{userInfo.profileImage && (
<Image source={{ uri: userInfo.profileImage }} style={{ width: 48, height: 48 }} />
)}
<Text>{userInfo.name}</Text>
<Text>{userInfo.email}</Text>
<Text>Signed in with: {userInfo.authConnection}</Text>
<Text>MFA enabled: {isMFAEnabled ? 'Yes' : 'No'}</Text>
</View>
)
}
Return type
import { type IUseWeb3AuthUser } from '@web3auth/react-native-sdk'
userInfo
Partial<AuthUserInfo> | null
Profile of the signed-in user, or null when signed out.
| Field | Type | Description |
|---|---|---|
email | string | Email address, when the auth provider shares it. |
name | string | Display name. |
profileImage | string | Profile image URL. |
userId | string | User identifier for the connection (for example, email or provider user ID). |
authConnection | string | Auth connection used to sign in (for example, google). |
authConnectionId | string | Connection ID used to sign in. |
groupedAuthConnectionId | string | Grouped connection ID, when the user signed in through a grouped connection. |
idToken | string | Embedded Wallets identity token, when available. |
oAuthIdToken | string | ID token from the OAuth provider, when available. |
oAuthAccessToken | string | Access token from the OAuth provider, when available. |
appState | string | Value you passed as appState to connectTo. |
dappShare | string | Dapp share for MFA-enabled custom connections. |
isMfaEnabled | boolean | Whether the user has enabled MFA. |
isMFAEnabled
boolean
Whether the user has enabled MFA.
getUserInfo
() => Promise<Partial<AuthUserInfo> | null>
Reads the user profile from the current session again and updates userInfo and isMFAEnabled.
loading
boolean
true while getUserInfo runs.
error
Web3authRNError | null
Error from the most recent getUserInfo call, or null.