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 codeOne-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
Sign In
Section titled “Sign In”Signing in with an email OTP is a two-step process:
Step 1: Request OTP
Section titled “Step 1: Request OTP”The user requests an OTP, which is sent to their email address:
await nhost.auth.signInOTPEmail({ email: 'user@example.com',});nhost.auth.signInEmailOTP(email: "user@example.com");Step 2: Verify OTP
Section titled “Step 2: Verify OTP”The user enters the OTP code received via email:
await nhost.auth.verifySignInOTPEmail({ email: 'user@example.com', otp: '123456',});nhost.auth.verifyEmailOTP(email: "user@example.com", otp: "123456");