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

useEnableMFA

Hook to start multi-factor authentication (MFA) setup for the signed-in user.

Import​

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

Usage​

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

function EnableMFAButton() {
const { enableMFA, loading, error } = useEnableMFA()
const { isMFAEnabled } = useWeb3AuthUser()

if (isMFAEnabled) return <Text>MFA is enabled</Text>

return (
<View>
<Button
title={loading ? 'Setting up MFA…' : 'Enable MFA'}
disabled={loading}
onPress={() => enableMFA()}
/>
{error && <Text>{error.message}</Text>}
</View>
)
}

Return type​

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

enableMFA​

() => Promise<void>

Opens the MFA setup flow in the in-app browser, where the user adds backup factors such as a device share, recovery phrase, or authenticator app. When the flow completes, the SDK refreshes the session and useWeb3AuthUser().isMFAEnabled becomes true. If MFA is already enabled, enableMFA sets error instead of opening the flow.

loading​

boolean

true while the MFA setup flow is in progress.

error​

Web3authRNError | null

Error from the most recent enableMFA call, or null.