Appearance
Documentation / expo / useRegisterMfaListener
Function: useRegisterMfaListener()
useRegisterMfaListener(
callbacks
):void
Use this hook to register your app's logic for prompting users to complete MFA. When a user is required to complete MFA in order to use their embedded wallet, Privy will invoke the logic you register here to have the user complete MFA. This hook should be mounted somewhere towards the root of your application tree so that it can handle MFA required events from the entire application.
Parameters
• callbacks: Object
callbacks to register your logic for prompting users to complete MFA.
• callbacks.onMfaRequired: (mfaMethods
) => void
| Promise
<void
>
Privy will invoke this callback whenever the user is required to complete MFA. Pass in a function that will prompt your user to complete MFA with Privy (using useMfa
) and only returns once MFA has been completed.
Returns
void
Example
ts
const [mfaMethods, setMfaMethods] = useState([])
const [isMfaDialogOpen, setIsMfaDialogOpen] = useState(false)
// Prompt user to select from their enabled MFA methods
useRegisterMfaListener({
onMfaRequired: async (methods) => {
setMfaMethods(methods)
setIsMfaDialogOpen(true);
},
});
// Within MFA modal allow the user to select an MFA method
<MFAModal
mfaMethods={mfaMethods}
isOpen={isMfaDialogOpen}
setIsOpen={setIsMfaDialogOpen}
/>
See `useMfa` for how to execute the MFA flow within Privy in your App.