Skip to content

Email OTP

Learn how to sign in users with one-time passwords delivered via email.

OTP one-time password passwordless email verification temporary code 2FA authentication code

One-Time Passwords (OTPs) are temporary codes for single use that can be delivered to users via email. OTPs expire after 5 minutes and can only be used once. OTPs can provide a more secure and convenient alternative to regular passwords.

To use One-Time Passwords, they need to be enabled in the configuration:

[auth.method.otp.email]
enabled = true

Signing in with an email OTP is a two-step process:

The user requests an OTP, which is sent to their email address:

await nhost.auth.signInOTPEmail({
email: 'user@example.com',
});

The user enters the OTP code received via email:

await nhost.auth.verifySignInOTPEmail({
email: 'user@example.com',
otp: '123456',
});