Enable MFA methods in the Privy
Dashboard before implementing this
feature.
Enrolling users in MFA
Once you have enabled MFA for your app, to prompt your users to enroll in MFA for their embedded wallet, use theshowMfaEnrollmentModal
method from the useMfaEnrollment
hook.Example button for enrolling in wallet MFA

Managing MFA methods
To allow your users to modify their MFA methods, simply invoke theshowMfaEnrollmentModal
method from the useMfaEnrollment
hook. This is the same method you would use to prompt your user to enroll in MFA for the first time.Within this modal, users can remove existing MFA methods or enroll in additional ones for their embedded wallet. Prior to making changes to their MFA methods, users will be prompted to re-verify their identity using one of their existing MFA methods.By default, removing a passkey as MFA will also unlink it as a valid login method. In order to modify this behavior, you can set the
shouldUnlinkOnUnenrollMfa
option to false
under the passkeys
config in PrivyProvider
.Authorizing signatures and transactions
Once a user has enrolled in MFA, every attempt to use the wallet’s private key (every signature or transaction) will require the user to complete MFA using their method. This logic is automatic; you do not need to do anything else once your user has enrolled in wallet MFA.When your app requests a signature or a transaction from the embedded wallet, Privy will show the user a modal prompting them to enter a 6-digit MFA code sent to their MFA method. If the user has enrolled in multiple MFA methods, they can choose which method they’d like to use for this given request.
Manually prompting for MFA verification
If you want to manually prompt your users for MFA verification, you can use theuseMfa
hook. The useMfa
hook provides a set of functions and state for managing MFA flows in your application. It allows you to:- Prompt the user to complete MFA verification if required.
- Initialize and submit MFA challenges (e.g., sending and verifying codes).
- Cancel and ongoing MFA flow.
- Access the list of available MFA methods for your app.
useMfa
hook to prompt for MFA verification:Example button for prompting MFA verification
promptMfa
function is called. If the user has enrolled in MFA, they will be prompted to complete the verification process. If successful, you can execute your desired actions after the verification.