Blog ·

Sign-up or reset link says "Email link is invalid or has expired"? Here is the fix

You built your app with Lovable, Bolt, Cursor or Replit, with Supabase handling sign-up and login. The emails arrive. But some users click the confirmation or password reset link and land on an error instead: "Email link is invalid or has expired", sometimes with otp_expired in the address bar. Often it works fine for you and fails only for some people.

The usual cause is not your code. Supabase's email links can only be used once, and something can use the link before your user does.

The short answer

Supabase's troubleshooting guide says the most common reason for these errors is email prefetching: some email providers and security tools automatically open links in incoming emails to scan them. Supabase's email template docs give Safe Links in Microsoft Defender for Office 365 as an example. When that happens, the one-time link is used up straight away, so when your real user clicks it, Supabase says it is invalid or expired.

The lasting fix is to change your email so that opening the link does not use it up: either send a code the user types into your app, or link to a page of yours with a button that does the real confirmation.

Other reasons the link fails

  • The link really did expire. Supabase's docs say email links expire after 1 hour by default, and one setting, Email OTP expiration, controls confirmation, password recovery, email change, invite and magic links.
  • Your email provider rewrites links for click tracking. Supabase says that if an external email provider has email tracking on, the links in its email templates are overwritten and won't work as expected, and recommends turning email tracking off.
  • The link was opened in a different browser. If your app uses Supabase's PKCE flow, Supabase's docs say the final step must happen on the same browser and device where the flow was started. The error message may differ, but the effect for your user is the same: the link doesn't sign them in.

How to tell which one it is

Supabase suggests checking your logs in the Supabase dashboard:

  1. In the API logs, look for 403 responses on the /verify endpoint. These are failed attempts to use an email link or code.
  2. In the Auth logs, look for the otp_expired error code around the same time.
  3. Compare the times. Supabase says that if you see these errors shortly after an email is sent, before a person could reasonably have clicked it, that strongly suggests prefetching.

If the failures come hours after the email was sent, the link most likely expired. If you send emails through your own provider, also check whether click tracking is switched on for your sending domain.

Fix it

1. Stop the link from being used up by scanners

Supabase's email template docs give two options.

Option 1: send a code instead of a link. Edit the email template to include {{ .Token }}, the 6-digit code Supabase generates, and add a page to your app where the user enters their email and that code. Your app then checks the code with supabase.auth.verifyOtp. Supabase's examples use type: 'email' for sign-up and sign-in codes, and its troubleshooting guide uses type: 'recovery' for password resets. A scanner can't use up a code it can't type.

Option 2: link to a page with a button. Change the link in the email so it opens a page on your own site, passing the real confirmation link along, for example {{ .SiteURL }}/confirm-signup?confirmation_url={{ .ConfirmationURL }}. That page shows a button containing the real confirmation link. A scanner that opens the email link only loads your page; the one-time link is used when your user clicks the button.

On your own Supabase project, edit templates on the Email Templates page in the Supabase dashboard. On Lovable's built-in backend, Lovable's docs say you can customise the reset email and the other templates under More → Emails, and that Lovable can build a one-time code flow for sign-in if you ask.

2. Turn off click tracking for auth emails

If you send Supabase's emails through your own provider (custom SMTP), check its tracking settings and switch click tracking off for the domain that sends your sign-up and reset emails. In Resend, for example, open and click tracking are off by default and are set per domain under the domain's Configuration tab.

3. Check how long links last

On your own Supabase project, the setting is under Authentication → Sign In / Providers → Auth Providers → Email → Email OTP expiration. The default is 1 hour. Supabase strongly discourages anything over 86,400 seconds (one day), which can only be set through its Management API. On Lovable's built-in backend, the same setting is under More → Users → Settings → Email, in the One-time codes section, from 60 seconds to 24 hours. A longer expiry does not stop scanners using up the link, so do step 1 first.

4. Test it like a new user

Sign up with a fresh email address on your live site and click the confirmation link. Then request a password reset and use that link too. If possible, test with a work email address as well as a personal one, since scanning is often done by security tools used by organisations. If someone still sees the error, ask them to request a new email and click the link straight from their inbox. Supabase also suggests telling users not to forward password reset emails.

A prompt you can paste into your AI tool

"Some users who click the confirmation or password reset link in my app's Supabase emails see 'Email link is invalid or has expired'. I think email security scanners are opening the one-time link first. Change my sign-up confirmation and password reset emails to include the 6-digit code {{ .Token }}, and add a page where the user enters their email and that code, verified with supabase.auth.verifyOtp (type 'email' for sign-up, type 'recovery' for password reset). Then let a user who reset their password set a new one. Don't change anything else, and tell me which email templates I need to update."

Then test sign-up and password reset again on the live site with a fresh email address.

Catch silent breaks before your users do

This kind of break is easy to miss because everything looks fine when you test it yourself. Scheduled testing from FlowCanary is launching by 30 November 2026. Once it is live, it will test the flows a new visitor can do in your app, such as sign-up and checkout, in a real browser on a schedule, with logged-in flows on Pro, and tell you in plain English when one breaks, with a fix prompt for Lovable, Bolt, Cursor or Replit. Until then, the free check works today: paste your live URL and it opens the page in a real browser and reports JavaScript errors, failed requests and blank pages.

Sources

Run the free checker