Sign users in without a password by validating a code sent to their email.
Passwordless authentication
Better Auth · Module
signIn.emailOtp() signs a user in with an email address and the one-time password sent to it. It is part of Better Auth's Email OTP plugin and supports optional first-registration profile fields.
After the user requests and receives a sign-in OTP through the Email OTP plugin, call this client method with the email address and code. Optional name and image values can supply profile details only when the OTP flow registers a new user.
authClient.signIn.emailOtp({ email, otp, name?, image? })| Name | Type | Description |
|---|---|---|
email | string, required | Email address to sign in. |
otp | string, required | OTP sent to the email. |
name | string, optional | User display name; used only when registering for the first time. |
image | string, optional | User profile image URL; used only when registering for the first time. |
The page documents the client call and its response destructuring as { data, error }; it does not specify a more detailed return schema in the fetched content.
import { authClient } from "@/lib/auth-client";
const { data, error } = await authClient.signIn.emailOtp({
email: "user@example.com",
otp: "123456",
});
if (error) {
console.error(error);
} else {
console.log(data);
}Submit the email and received OTP to authenticate the user.
Passwordless authentication
Just-in-time registration
Email-based account flows
The method accepts the user's email and the OTP delivered to that address. It submits them to the email-OTP sign-in endpoint and returns the authentication result or an error.
Follow-up: What optional registration data can be supplied? The request may include name and image, but those values are used only when the user is registering for the first time.
The client method corresponds to POST /sign-in/email-otp. The email identifies the account or registration target, while otp is the one-time code sent for sign-in.
Follow-up: How would the server invoke the same operation? Use the server API's signInEmailOTP operation with the request body containing the same fields.
The Email OTP plugin supports passwordless sign-in by sending a one-time password to the user's email and then accepting that code through signIn.emailOtp().
Follow-up: What other plugin capabilities are documented? The same Email OTP plugin also supports email verification and password reset using one-time passwords.
Email OTP pluginsendVerificationOtp()signInEmailOTPPOST /sign-in/email-otp