Fix guides · Lovable, Bolt, Cursor, Claude Code, v0 ·

Fix Supabase "AuthSessionMissingError: Auth session missing!"

AuthSessionMissingError: Auth session missing!

"Auth session missing!" means a Supabase auth call that needs a logged-in user (getUser, updateUser, signOut) found no session at all. The Supabase client throws it before it even asks the server. Usually the code runs in a place where the login cookie or token isn't available: a server client that doesn't read cookies, a check that runs before the session is restored, or a password reset page that never set up the recovery session.

Free · 3 a day · no signup

Common causes – and how to tell which one you have

1. The server-side client doesn't read the login cookies

How to tell: The error shows up in a route handler, server action or server component, while the same user looks logged in on the client. The server code uses createClient from @supabase/supabase-js or builds a client without passing cookies.

Fix: Create the server client with createServerClient from @supabase/ssr and pass the request cookies (getAll/setAll). Add the Supabase middleware (proxy.ts in Next.js 16) that refreshes the session on each request.

2. The check runs before the session is restored

How to tell: It happens right after a page load or refresh, sometimes only on the first render, and works if you click again a second later.

Fix: Subscribe to supabase.auth.onAuthStateChange and act on the INITIAL_SESSION or SIGNED_IN event, or await getSession() before calling getUser() or updateUser().

3. The password reset page has no recovery session

How to tell: updateUser({ password }) fails with this error after the user opens the reset link from the email, often on mobile or when the link was opened in a different browser than the one that requested it.

Fix: On the reset page, wait for the PASSWORD_RECOVERY event from onAuthStateChange (or call exchangeCodeForSession with the code in the URL when you use PKCE) before calling updateUser. Tell users to open the link in the same browser they requested it from.

4. Browser and server use different storage

How to tell: The browser client is created with createClient from @supabase/supabase-js (session in localStorage), but the server expects cookies. Login works in the browser, every server request says the session is missing.

Fix: In a Next.js or SSR app, create the browser client with createBrowserClient from @supabase/ssr so the session is stored in cookies the server can read.

5. The user really is logged out

How to tell: The error appears for visitors who never logged in, or after signOut or an expired session, for example when a page calls getUser() for everyone.

Fix: This is expected. Check for the error (error.name === 'AuthSessionMissingError' or isAuthSessionMissingError) and treat it as "no user": show the login button or redirect to /login.

How to fix it

  1. Find where the error is thrown: in the browser console (client code) or in the server/terminal log (server code, route handler, server action).
  2. If it's server code, check how the Supabase client is created there. It must be built from the request cookies with createServerClient from @supabase/ssr, not with a plain createClient.
  3. If it's client code, check whether it runs on page load. Wait for the session with onAuthStateChange or getSession() before calling getUser() or updateUser().
  4. If it happens on the password reset page, make sure the page waits for the PASSWORD_RECOVERY event (or exchanges the code from the link) before calling updateUser({ password }).
  5. If the user is simply logged out, treat this error as "not logged in" and redirect to the login page instead of showing an error.
  6. Log in again in a normal browser window and repeat the action to confirm the error is gone.

Using Lovable, Bolt or v0?

In Lovable or Bolt, paste the full error and say where it happens (page load, reset password page, after login). Then ask: "Only call Supabase auth methods after the session is loaded via onAuthStateChange, and treat a missing session as logged out instead of an error." Then test once in a fresh browser window.

Using Cursor, Claude Code or Windsurf?

Ask Cursor or Claude Code to list every supabase.auth call and say for each one whether it runs on the server or the client, and which client factory it uses. In Next.js, have it compare the setup with the official @supabase/ssr Next.js guide (server client, browser client, middleware) and fix the differences.

The “fix” to avoid

Agents often store the access token in localStorage by hand and pass it around, or turn off the check and assume a user exists. The first breaks token refresh and leaks tokens; the second crashes later with null errors. Fix where the client gets its session instead.

Copy-paste fix prompt for your AI coding tool

Paste this into Cursor, Claude Code, Lovable or Bolt:

My app throws "AuthSessionMissingError: Auth session missing!" from Supabase. Find every place that calls supabase.auth.getUser(), updateUser() or signOut(). For server code (route handlers, server actions, server components), make sure the client is created with createServerClient from @supabase/ssr using the request cookies, and that middleware refreshes the session. For client code, make sure it waits for the session (onAuthStateChange) before calling auth methods, and that the browser client is createBrowserClient from @supabase/ssr. On the password reset page, wait for the PASSWORD_RECOVERY event before updateUser. Treat a missing session for logged-out users as "redirect to login", not as a crash. Show me what you changed.
Your error looks a bit different? Paste your exact error and get a diagnosis tailored to your code — free.

Questions people ask

Is "Auth session missing" the same as an expired session?

No. An expired or revoked session usually shows up as a refresh token error or a 401. "Auth session missing" means the client had no session to send at all.

Why does it only fail on the server?

The server only knows the user through cookies. If the session is kept in localStorage, or the server client doesn't read cookies, the server never sees the login.

Should I use getSession() or getUser() on the server?

Use getUser() (or getClaims() in newer versions) to check who the user is on the server. It verifies the token with Supabase. getSession() only reads the cookie and shouldn't be trusted for access decisions.

Official documentation

Related errors

Get fixes like this every week