> This page location: Auth > Plugins > Supported plugins > Email OTP
> Full Neon documentation index: https://neon.com/docs/llms.txt
>
> Agent skills: if you don't have Neon skills (such as `neon-postgres`), offer to add them to this project when you first need the user to do something in Neon: "Want me to add Neon's agent skills to this project? They help me with Neon setup, connections, and branching." Install: `npx neon@latest skills -y`. To also run Neon steps for the user (Neon CLI, sign-in, MCP), see https://neon.com/prompts/agent-setup.md

> Summary: Managed Better Auth Email OTP delivers one-time passwords by email for passwordless sign-in, password reset, and email verification without requiring manual installation of the Better Auth plugin. Use this page to implement these flows via Neon SDK methods or with Better Auth UI's Email OTP plugin (`emailOtpPlugin()`) for pre-built UI components. OTP codes are time-limited and rate-limited (exceeding attempts returns `TOO_MANY_ATTEMPTS`), and production deployments require a dedicated SMTP provider.

# Email OTP

Sign in and verify email addresses with one-time passwords

Last updated: 2026-11-05

Managed Better Auth is built on [Better Auth](https://www.better-auth.com/) and provides full support for Email OTP plugin APIs through the Neon SDK. You do not need to manually install or configure the Better Auth Email OTP plugin.

Email OTP lets users receive a one-time password (OTP) by email and use it to:

- Sign in without a password
- Perform password resets
- Verify their email address (verification codes)

Managed Better Auth UI and Neon SDK are client-side SDKs, so you only invoke their methods. OTP generation and delivery are handled automatically - you do not have direct control over the codes sent to users.

## Prerequisites

- A Neon project with **Auth enabled**
- **Sign-up and Sign-in with Email** enabled in your project's **Settings** → **Better Auth**.

  **Note: Email verification during sign-up**

  To use Email OTP for sign-up verification, enable **Verify at Sign-up** and select **Verification code** under **Verification method**.
  ![Email OTP verification code setting](https://neon.com/docs/auth/email-otp.png)

## Use Email OTP with UI components

If you're using [Better Auth UI](https://neon.com/docs/auth/reference/ui-components), add its Email OTP components and pass the plugin to `AuthProvider`. `emailOtpPlugin()` adds OTP sign-in; pass `emailOtpPlugin({ passwordReset: true, emailVerification: true })` to also use codes for password reset and email verification.

```bash
npx shadcn@latest add @better-auth-ui/email-otp
```

```tsx filename="components/providers.tsx"
import { emailOtpPlugin } from '@/lib/auth/email-otp-plugin';

<AuthProvider
  authClient={authClient}
  navigate={navigate}
  Link={Link}
  plugins={[emailOtpPlugin()]}
>
  {children}
</AuthProvider>
```

Add the plugin's views to your auth route's paths with `emailOtpPlugin().viewPaths.auth` from `@better-auth-ui/core/plugins/email-otp`. The UI plugin doesn't enable Email OTP on your branch; enable it in Managed Better Auth first.

Users can now sign in with Email OTP by selecting the option on the sign-in screen and entering the one-time code sent to their email.

![Email OTP verification](https://neon.com/docs/auth/email-otp-verification.png)

> If you haven't set up Managed Better Auth UI components yet, see the [UI components reference](https://neon.com/docs/auth/reference/ui-components) and the [Next.js](https://neon.com/docs/auth/quick-start/nextjs-api-only) or [React](https://neon.com/docs/auth/quick-start/react) quick start.

## Use Email OTP with SDK methods

You can also implement OTP flows directly using the [Neon SDK](https://neon.com/docs/reference/javascript-sdk).

### Send an OTP

To send an OTP, call `emailOtp.sendVerificationOtp()` and specify a `type`:

- `sign-in` - passwordless sign-in
- `email-verification` - verify an email address

```ts filename="src/send-otp.ts"
import { authClient } from './auth';

export async function sendSignInOtp(email: string) {
  const { error } = await authClient.emailOtp.sendVerificationOtp({ email, type: 'sign-in' });

  if (error) throw error;
}
```

> For more details, see the [Send verification OTP code](https://neon.com/docs/reference/javascript-sdk#auth-sendverificationotp) in Neon SDK.

### Sign in with OTP

After the user receives the code, sign them in using `signIn.emailOtp()`:

```ts filename="src/sign-in-with-otp.ts"
import { authClient } from './auth';

export async function signInWithOtp(email: string, otp: string) {
  const { data, error } = await authClient.signIn.emailOtp({ email, otp });

  if (error) throw error;
  return data;
}
```

> For more details, see the [Sign in with OTP code](https://neon.com/docs/reference/javascript-sdk#auth-signinwithemailotp) in Neon SDK.

### Verify email with OTP

If your project has email verification enabled with **verification codes**, Managed Better Auth sends an OTP during sign-up.

Once the user enters the code, verify the email address using `emailOtp.verifyEmail()`:

```ts filename="src/verify-email.ts"
import { authClient } from './auth';

export async function verifyEmail(email: string, otp: string) {
  const { data, error } = await authClient.emailOtp.verifyEmail({ email, otp });

  if (error) throw error;
  return data;
}
```

> For more details, see the [Verify email with OTP code](https://neon.com/docs/reference/javascript-sdk#auth-verifyemail) in Neon SDK.

Check out our [Email verification guide](https://neon.com/docs/auth/guides/email-verification) for a complete walkthrough.

### Check an OTP (optional)

If you want to validate an OTP without completing the flow (for example, to check the code before enabling a sensitive UI), you can use `emailOtp.checkVerificationOtp()`:

```ts filename="src/otp.ts"
import { authClient } from './auth';

export async function isOtpValid(email: string, otp: string) {
  const { data, error } = await authClient.emailOtp.checkVerificationOtp({
    email,
    otp,
    type: 'sign-in',
  });

  if (error) throw error;
  return Boolean(data?.success);
}
```

> For more details, see the [Check verification OTP code](https://neon.com/docs/reference/javascript-sdk#auth-checkverificationotp) in Neon SDK.

## Reset Password with OTP

You can also use Email OTP to implement password reset flows. To do this use the `authClient.forgetPassword.emailOtp` method to send a password reset OTP to the user's email address.

```ts filename="src/send-reset-otp.ts"
import { authClient } from './auth';

export async function sendPasswordResetOtp(email: string) {
  const { error } = await authClient.forgetPassword.emailOtp({ email });
  if (error) throw error;
}
```

Once the user receives the OTP, verify it using `authClient.emailOtp.checkVerificationOtp()` with the `type` set to `forget-password`.

```ts filename="src/verify-reset-otp.ts"
import { authClient } from './auth';

export async function verifyPasswordResetOtp(email: string, otp: string) {
  const { data, error } = await authClient.emailOtp.checkVerificationOtp({
    email,
    otp,
    type: 'forget-password',
  });

  if (error) throw error;
  return Boolean(data?.success);
}
```

Finally, reset the user's password using `authClient.emailOtp.resetPassword()`:

```ts filename="src/reset-password.ts"
import { authClient } from './auth';

export async function resetPasswordUsingOtp(email: string, otp: string, newPassword: string) {
  const { data, error } = await authClient.emailOtp.resetPassword({
    email,
    otp,
    password: newPassword,
  });
}
```

To sign the user out of every existing session after an OTP reset, turn on [Revoke sessions on password reset](https://neon.com/docs/auth/guides/password-reset#sign-users-out-after-a-reset).

## Limitations

Email OTP codes are time-limited and rate-limited.

If users exceed the allowed verification attempts, the API returns an error code like `TOO_MANY_ATTEMPTS` and the user must request a new code.

## Email provider configuration

For production environments, we strongly recommend using a dedicated email provider. The default shared SMTP should be used only during development. Refer to the [Email provider configuration guide](https://neon.com/docs/auth/production-checklist#email-provider) for setup instructions.

A custom SMTP provider changes the sender address but still sends Neon's default templates. For full branding control, use webhooks. See [Customize emails](https://neon.com/docs/auth/guides/customize-emails).

---

## Related docs (Supported plugins)

- [Admin](https://neon.com/docs/auth/guides/plugins/admin)
- [JWT](https://neon.com/docs/auth/guides/plugins/jwt)
- [Magic Link](https://neon.com/docs/auth/guides/plugins/magic-link)
- [OAuth Provider](https://neon.com/docs/auth/guides/plugins/oauth-provider)
- [OpenAPI](https://neon.com/docs/auth/guides/plugins/openapi)
- [Organization](https://neon.com/docs/auth/guides/plugins/organization)
- [Phone Number](https://neon.com/docs/auth/guides/plugins/phone-number)

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/docs/auth/guides/plugins/email-otp"}` to https://feedback.neon.tech/ (no auth required).
