Appearance
Documentation / react-auth / 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
PrivyEvents callbacks to register your logic for prompting users to complete MFA.
• callbacks.onMfaRequired: (mfaMethods
) => void
Callback that will execute when MFA is required to complete a given action.
Param[] - List of MFA methods that the user can choose from
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.