The Email OTP screen automatically appears after a user enters their email address in the login modal.
How it works
When a user selects email authentication:- User enters their email address in the login modal
- MoonKey sends a one-time passcode to the email
- The Email OTP screen appears, prompting the user to enter the code
- User enters the 6-digit code
- Upon successful verification, the user is authenticated
Customizing the Email OTP screen
You can customize the Email OTP experience by configuring theemailOtp prop in your MoonKeyProvider:
Configuration options
Email OTP behavior
Skip showing the success screen after email verification and immediately proceed to the application.When
true, users won’t see a success message and will be taken directly to your app after entering the correct OTP.Example:Time in seconds before the OTP expires.Default:
600 (10 minutes)Example:Time in milliseconds to display the success message before closing the modal.Only applies when
skipVerifiedSuccess is false.Default: 3000 (3 seconds)Example:Time in seconds before users can request a new OTP code.Default:
30 (30 seconds)Example:UI customization
Title text displayed on the email verification screen.Example:
Title text for the resend code prompt.Example:
Success message shown to new users after verification.Displayed when a user successfully verifies their email for the first time.Example:
Success message shown to existing users after verification.Displayed when a returning user successfully verifies their email.Example:
Generic success message shown after verification.This is a fallback message when MoonKey cannot determine if the user is new or existing.Example:
Common configurations
Quick verification (skip success screen)
For a streamlined experience, skip the success screen and authenticate users immediately:Custom timing
Adjust OTP expiration and resend cooldown for your security requirements:Custom messaging
Personalize the verification flow with custom messages:Enterprise security settings
For enterprise applications requiring stricter security:General appearance customization
In addition to Email OTP-specific settings, you can customize the general appearance that applies to all UI components, including the Email OTP screen:Complete example
Here’s a complete example with all Email OTP customization options:User experience flow
Here’s what the complete email authentication flow looks like with Email OTP:1
User initiates login
User clicks “Sign in” button, opening the login modal.
2
Enter email address
User selects email authentication and enters their email address.
3
Email OTP screen appears
The Email OTP screen appears, prompting the user to enter the code.
4
Check email
User checks their email inbox for the 6-digit verification code.
5
Enter verification code
User enters the code on the Email OTP screen.
6
Verification & authentication
MoonKey verifies the code. If valid:
- Shows success message (unless
skipVerifiedSuccess: true) - Authenticates the user
- Creates embedded wallet (if
createOnLogin: 'always') - Closes the modal and returns user to the app
Resending codes
If a user doesn’t receive the OTP or it expires, they can request a new code:- User clicks “Resend code” link on the Email OTP screen
- MoonKey enforces the
resendCodeTimecooldown - A new OTP is sent to the user’s email
- User enters the new code
Handling errors
The Email OTP screen automatically handles common errors:- Invalid code - Shows an error message and allows the user to try again
- Expired code - Prompts the user to request a new code
- Too many attempts - May temporarily lock verification (contact support if this occurs)
Best practices
Choose appropriate expiration times
Choose appropriate expiration times
- Consumer apps: 5-10 minutes is typical
- Enterprise apps: 3-5 minutes for higher security
- Consider your users’ email access patterns
Set reasonable resend cooldowns
Set reasonable resend cooldowns
- Recommended: 30-60 seconds
- Prevents spam while allowing legitimate resend requests
- Too short: risk of abuse
- Too long: frustrates users
Provide clear success messages
Provide clear success messages
- Differentiate between new and returning users
- Use friendly, encouraging language
- Consider your brand voice
Consider skipping success screen
Consider skipping success screen
- For faster authentication, set
skipVerifiedSuccess: true - Best for apps where speed is critical
- Still provide feedback in your app after authentication
Test the complete flow
Test the complete flow
- Test with various email providers (Gmail, Outlook, etc.)
- Check spam folders to ensure delivery
- Verify timing configurations work as expected
- Test resend functionality
TypeScript interface
For TypeScript users, here’s the completeEmailOtpConfig interface: