Supabase says Auth session missing when a user resets a password in Next.js
AuthSessionMissingError: Auth session missing!Short answer
The error means your code called Supabase without a signed-in session. On a reset page this usually happens because the default email link puts the session in the URL fragment, which a server cannot read. Send the link to a route that calls verifyOtp with token_hash, and make sure the session cookie is refreshed on every request.
Fix it fast
1Find out which cause you have
Log what the server client sees on the reset page, before calling updateUser. If user is null, no session cookie reached the server.
const { data, error } = await supabase.auth.getUser() console.log(data.user, error?.name)2Match what you see, then jump to its fix
- 1
The page opens from the email link, but a Server Component or Server Action sees no userThe reset email uses the default link, so the server never gets the sessionFix - 2
Token has expired or is invalid, even though the link is brand newAn email scanner opened the link firstFix - 3
Signed-in calls work for a while, then the server stops seeing the userThe session cookie is not refreshed on each requestFix - 4
The call is made from server code or a client created without the request cookiesupdateUser runs on a client that holds no logged-in userFix
- 1
What does the error look like?
AuthSessionMissingError: Auth session missing!Token has expired or is invalid
Cause 1 of 4
The reset email uses the default link, so the server never gets the session
1Check
The email template docs say the default confirmation link returns the session in the URL fragment, and the server cannot read a fragment. Look at your Reset Password template for the variable it uses.
# Dashboard > Authentication > Email Templates > Reset Password
# look for {{ .ConfirmationURL }}2Fix
Change the template to link to your own route with the token hash, then verify it on the server. The Supabase password guide shows this exact template and a Next.js route handler.
<!-- Reset Password template -->
<a href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=recovery&next=/account/update-password">Reset password</a>
// app/auth/confirm/route.ts (core of the handler)
const { error } = await supabase.auth.verifyOtp({ type, token_hash })
if (!error) {
return NextResponse.redirect(redirectTo)
}3Verify
Request a new reset email, click it, and confirm the update-password page now shows a user.
# after clicking the link, getUser() returns the user instead of AuthSessionMissingErrorConfirmed by supabase.com
Cause 2 of 4
An email scanner opened the link first
1Check
The email template docs warn that some email providers prefetch links, which can use up a ConfirmationURL before the person clicks. No session is created for the real click.
# Compare the time the link was sent with the time the error was logged2Fix
Use the token_hash link from the first cause, or an email one-time code, so a prefetch cannot consume the token.
<a href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=recovery&next=/account/update-password">Reset password</a>3Verify
Send yourself a reset email through the affected provider and click it once.
# the update-password page loads signed inConfirmed by supabase.com
Cause 3 of 4
The session cookie is not refreshed on each request
1Check
With @supabase/ssr, a proxy refreshes the session and writes the cookies. The Supabase Next.js guide says the file is proxy.ts in Next.js 16, and that on Next.js 15 and earlier a proxy.ts file is never called, so sessions never refresh.
ls middleware.ts proxy.ts src/middleware.ts src/proxy.ts 2>/dev/null2Fix
Name the file for your Next.js version (middleware.ts up to 15, proxy.ts from 16), and return the response object the setAll callback built.
npx next --version
# Next.js 15 or older: middleware.ts
# Next.js 16 or newer: proxy.ts3Verify
Wait past the access token lifetime, reload the page and call getUser again.
# getUser() still returns the userConfirmed by supabase.com
Cause 4 of 4
updateUser runs on a client that holds no logged-in user
1Check
The updateUser reference says it updates data for a logged in user. The Next.js guide says to use a browser client in Client Components and a server client, built from the request cookies, in server code.
grep -rn "createClient\|createServerClient\|createBrowserClient" app lib utils2Fix
Call updateUser from a client built for that place: the server client in a Server Action, the browser client in a Client Component.
// Server Action, with the server client
const supabase = await createClient()
const { error } = await supabase.auth.updateUser({ password })3Verify
Submit the new password and check that error is null.
# error is null and the user can sign in with the new passwordConfirmed by supabase.com
How do I stop it coming back?
- Write down in your repo that the Reset Password template must use the token_hash link, so nobody resets it to the default.
- Add the update-password page to your protected routes, so it redirects when there is no user.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
AuthUserPoolException: Auth UserPool not configured in a Next.js app
Auth UserPool not configured
The error means an Amplify Auth call ran before Amplify.configure did.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Clerk cannot read its publishable key in a Next.js app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is undefined
Clerk reads NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY.
3 causes, each with a fixWeb apps
The shell cannot find create-next-app
command not found: create-next-app
create-next-app is not meant to be installed as a shell command.
2 causes, each with a fixWeb apps
ESLint fails with: Cannot find module 'next/babel'
ESLint stops on the first file with a Babel or parser error instead of listing lint results
next/babel is a Babel preset that ships inside the next package.
3 causes, each with a fixWeb apps
ESLint says an element in a list is missing its key prop
react/jsx-key
react/jsx-key fires when an element returned from map, Array.from or an array literal has no key.
3 causes, each with a fix