Supabase Otp Expired Error

Supabase error otp_expired (otp_expired) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.

Error code otp_expired Supabase Last verified 2026-08-19

Quick Answer

Request a fresh code with signInWithOtp and have the user retry quickly. If that does not apply, verify the token type matches the flow (email vs SMS vs phone) — the full checklist is below.

Error Code

Error code: otp_expired
Official name: otp_expired
Service: Supabase

What does this error mean?

OTP code for this sign-in has expired. Ask the user to sign in again.

Common Causes

How to Fix

  1. Request a fresh code with signInWithOtp and have the user retry quickly
  2. Verify the token type matches the flow (email vs SMS vs phone)
  3. Keep verification state server-side instead of trusting client timestamps
  4. For email OTP, confirm the redirect URL is configured so links resolve before expiry

Code Examples

Auto-resend on expiry javascript
const { error } = await supabase.auth.verifyOtp({
  email,
  token: code,
  type: 'email',
})
if (error?.code === 'otp_expired') {
  // resend and let the user retry with the new code
  await supabase.auth.signInWithOtp({ email })
}

Auto-resending on otp_expired keeps the UX smooth, but respect the email rate limit.

Framework-Specific Fixes

supabase-js

Detect otp_expired and immediately offer a resend with a countdown.

if (error?.code === 'otp_expired') {
  startCountdown(60)
  showToast('Code expired - a new one was sent')
  await supabase.auth.signInWithOtp({ email })
}

You Might Also Like

Frequently Asked Questions

Why am I seeing Supabase error otp_expired?

Most often this happens when magic link or OTP code used after its expiry window, or when six-digit code typed too slowly (SMS OTP windows are short).

How do I fix Supabase error otp_expired?

Request a fresh code with signInWithOtp and have the user retry quickly.

Which frameworks have documented fixes for error otp_expired?

This page documents fixes for: supabase-js.

Official Sources

This page is based on the official Supabase documentation linked below and adds practical troubleshooting guidance on top.