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

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.

FieldTypeDescription
emailstringEmail address, when the auth provider shares it.
namestringDisplay name.
profileImagestringProfile image URL.
userIdstringUser identifier for the connection (for example, email or provider user ID).
authConnectionstringAuth connection used to sign in (for example, google).
authConnectionIdstringConnection ID used to sign in.
groupedAuthConnectionIdstringGrouped connection ID, when the user signed in through a grouped connection.
idTokenstringEmbedded Wallets identity token, when available.
oAuthIdTokenstringID token from the OAuth provider, when available.
oAuthAccessTokenstringAccess token from the OAuth provider, when available.
appStatestringValue you passed as appState to connectTo.
dappSharestringDapp share for MFA-enabled custom connections.
isMfaEnabledbooleanWhether 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.