Choose your approach
Pre-built components
Drop-in React modals and inline UI. Best for most apps.
React hooks
Build custom verification UI. Required for SMS.
Core SDK
Direct API calls. For non-React apps.
Ready-to-use components (recommended)
@coinbase/cdp-react provides ready-to-use components with a polished UI.
Pre-built components support TOTP (authenticator apps). For SMS verification, use React hooks below.
- Modal
- Programmatic
- Inline
For UI customization (controlled modals, custom layouts, transitions, render props), see the VerifyMfa component reference.
Custom UIs using React Hooks
For custom UI or SMS verification, use hooks from@coinbase/cdp-hooks.
Verification is a two-step process:
- Initiate — Call
useInitiateMfaVerificationto start verification (for SMS, this sends a new code) - Submit — Call
useSubmitMfaVerificationwith the 6-digit code to complete verification
- TOTP
- SMS
- Multiple methods
For complete UI implementations with error handling and state management, see the MFA section in the cdp-hooks reference.
Direct API calls for non-React
For non-React applications, use functions from@coinbase/cdp-core.
- TOTP
- SMS
For full API details, see the cdp-core reference.
Handling MFA errors
When a sensitive operation requires MFA, it throws an error with codeMFA_REQUIRED:
Troubleshooting
Invalid TOTP code
Invalid TOTP code
Common causes:
- Time synchronization issues between device and server
- User entering an expired code (TOTP codes refresh every 30 seconds)
- Incorrect authenticator app setup
- Ensure device time is synchronized with network time
- Ask users to wait for a new code and try again
- Verify the QR code was scanned correctly during enrollment
Invalid SMS code
Invalid SMS code
Common causes:
- User entering an expired code (SMS codes expire after 5 minutes)
- User entering enrollment code instead of verification code
- Wrong phone number entered during enrollment
- Ensure user is entering the most recent code
- For verification, remind users they need to initiate verification first to receive a new SMS
- Provide resend option with rate limiting
- Allow users to re-enroll with correct phone number
User has multiple methods enrolled
User has multiple methods enrolled
Solution:
- Use
getEnrolledMfaMethods(user)to get available methods - Present UI to let user choose their preferred verification method
- Store user’s preference for future verifications
- See the “Multiple methods” tab above for implementation
Lost authenticator app or phone access
Lost authenticator app or phone access
Recovery options:
- If user has both TOTP and SMS enrolled, they can use the other method
- Implement account recovery through primary authentication method
- Allow MFA reset after verifying via email or other auth method
- Provide customer support flow for account recovery