Guide
Supabase "Auth session missing!": the fix
How this guide was made: Written with AI assistance and checked against the sources linked on this page.
Updated
Short answer: Supabase returns "Auth session missing!" (AuthSessionMissingError) when your code calls a method that needs a signed-in session, such as updateUser(), and the browser or server has no session to use. Fix it by checking for a session before the call. On a password reset link, exchange the code for a session first.
Something broke on your live app? Tell us what happened. Our AI agent tries it on your live app and sends you a screenshot, free. Check my app free
What does "Auth session missing!" mean?
It means the Supabase client was asked to do something that needs a session, and there is no session to use. The error name is AuthSessionMissingError and the message is "Auth session missing!" (auth-js: errors.ts).
The library raises it in several places in auth-js GoTrueClient. Three matter for your app:
- getUser() returns it as an error with no user. It does not throw. The call passes back
{ data: { user: null }, error }, so your code has to read the error field (auth-js: GoTrueClient.ts). - updateUser() raises it when there is no session. The client turns that into an error result for your code (auth-js: GoTrueClient.ts).
- refreshSession() and setSession() raise it when no refresh token or no session is available (auth-js: GoTrueClient.ts).
Supabase says to use the name property to identify the error class (Supabase: Auth error codes). Our suggestion: check for AuthSessionMissingError in your code, not for the message text.
Which cause is it?
| What you see | Cause | Fix |
|---|---|---|
| updateUser() or getUser() fails on a page where no one is signed in | Your code calls a signed-in method with no session | Cause 1 |
| The error appears on the page that opens from a password reset email | The reset code was not exchanged for a session | Cause 2 |
| The error appears after sign-out, after a long idle time, or after signing in on another device | The session ended | Cause 3 |
| The error appears only in server code, middleware or API routes | The server cannot read the session from cookies | Cause 4 |
1. Your code calls a signed-in method with no session
Some calls need a signed-in user. If the page runs them before anyone has signed in, or for someone who is signed out, the error is returned. Supabase's getSession() returns a session that "can be null if the session is not detected which can happen in the event a user is not signed-in or has logged out" (Supabase: getSession()).
How to fix it
- Find the call that returns the error: updateUser(), getUser() or a password change.
- Before that call, read the session. On the client, use getSession().
- Our suggestion: if there is no session, send the person to your sign-in page and stop. Do not make the signed-in call.
- If there is a session, make the call and check the
errorfield of the result.
const { data: { session } } = await supabase.auth.getSession()
if (!session) {
// send the person to sign in
return
}
await supabase.auth.updateUser({ password: newPassword })
Source: Supabase: getSession(), Supabase: getUser()
2. The password reset link opens without a session
A reset link does not sign anyone in by itself. Supabase's password guide says that once you have a session, you collect the new password and call updateUser. Before that, the link's code has to be exchanged. In the PKCE flow, the code "has a validity of 5 minutes and can only be exchanged for an access token once", and "the code exchange must be initiated on the same browser and device where the flow was started" (Supabase: PKCE flow).
An Expo app reported this exact sequence: request a reset, open the email link, set a new password, then see "Auth session missing!" (supabase/supabase #25827). The report does not give a cause or fix. Use the steps below and check the result on your live app.
How to fix it
- On the reset page, exchange the link for a session before any password call. The password guide's example uses
verifyOtpwith thetoken_hashfrom the link:
const { error } = await supabase.auth.verifyOtp({
type,
token_hash,
})
- If your flow returns a
codein the URL instead, callexchangeCodeForSession(code). Supabase's PKCE page says the client can also do this automatically whendetectSessionInUrl: trueis set. - Call
updateUser({ password })only after that exchange returns no error. - If the link is older than 5 minutes, or was already used, send a new reset email and open the new link in the same browser where you asked for it.
Source: Supabase: Password-based auth, Supabase: PKCE flow
3. The session ended, or the refresh token was already used
Sessions end in several ways. Supabase lists these: the user clicks sign out, the user changes their password or performs a security-sensitive action, the session times out from inactivity, it reaches its maximum lifetime, or the user signs in on another device (Supabase: Sessions).
The error codes tell you which one happened:
session_expired: the session expired, for example after an inactivity timeout.session_not_found: the session no longer exists, for example after sign-out.refresh_token_already_used: the refresh token was used again outside the reuse interval, so the token is revoked.refresh_token_not_found: the session containing the refresh token was not found (Supabase: Auth error codes).
Supabase's sessions page says a refresh token "can only be used once", that a reuse within the default 10-second interval is allowed, and that "Should the reuse attempt not fall under these two exceptions, the whole session is regarded as terminated" (Supabase: Sessions).
How to fix it
- Catch the error on the page that needs the user. Check
error.nameforAuthSessionMissingError, orerror.codeforsession_expired,session_not_foundor the refresh token codes. - Send the person to sign in again.
- Our suggestion: do not run your own token refresh next to the client's automatic one. A second use of the same refresh token outside the 10-second interval ends the whole session.
- After the person signs in again, retry the action once.
Source: Supabase: Sessions, Supabase: Auth error codes
4. Server code cannot read the session from cookies
On a server, the session has to come from the request cookies. Supabase's Next.js guide says the server client needs the project URL, the publishable key, and a cookies object. The setAll function runs "whenever the library needs to write cookies". The default cookie name is sb-<project_ref>-auth-token (Supabase: Server-side auth for Next.js).
The guide also says the Next.js proxy refreshes the session by calling supabase.auth.getClaims(), and that it must return the supabaseResponse object that setAll last built. Without that return, the refreshed cookie does not reach the browser.
Supabase warns against trusting getSession() in server code: "Never trust supabase.auth.getSession() inside server code such as Proxy." It "reads the session out of the cookie without revalidating it" (Supabase: Server-side auth for Next.js).
How to fix it
- Create the server client with a
cookiesobject that reads the request's cookies and writes them withsetAll. - In your proxy or middleware, refresh the session and return the response that
setAllbuilt. - In server code, do not use getSession() to decide who the user is. Use getUser(), which Supabase says "performs a network request to the Supabase Auth server", or getClaims() for identity checks (Supabase: getUser()).
- Set the cache headers on the response so CDNs do not cache it.
If the cookie disappears after login, see Supabase auth cookie lost after login on Next.js in production.
Source: Supabase: Server-side auth for Next.js, Supabase: getUser()
How do I check it's fixed?
- Our suggestion: open your live app in a private (incognito) window.
- Sign in, then run the action that showed the error, such as changing the password.
- Confirm the action completes and no "Auth session missing!" appears.
- Sign out, then open the same page. Check that you are sent to sign in, not shown the error.
- For a reset link, request a new reset email, open it in the same browser, set a new password, then sign in with it.
FAQ
Does signing out cause "Auth session missing!"?
No. In auth-js, signOut() skips the server call when there is no access token, and it returns { error: null } unless the scope is others (auth-js: GoTrueClient.ts, Supabase: signOut()). The error comes from the call that needs the session afterwards.
Does getUser() throw this error?
It returns the error. Check the error field of the result instead of wrapping the call in try and catch alone (auth-js: GoTrueClient.ts).
Can I use getSession() on the server to check the user?
Supabase advises against it. Its docs say getSession() reads from cookies without checking them, and that anyone can forge the session cookie. Use getUser() or getClaims() on the server (Supabase: Server-side auth for Next.js).
Why does the reset link stop working?
The PKCE code is valid for 5 minutes and can be used once. The code exchange must be started on the same browser and device where the flow began (Supabase: PKCE flow). Our suggestion: send a new reset email and open it in the same browser.
Can VibeFix fix it for me?
Yes, for apps built in Lovable or any app whose code is on GitHub. The free check confirms the problem on your live app first. If you want it fixed, our AI agent finds the cause, fixes it in your code for $79 and tests your live app again. See pricing.
Want it fixed?
VibeFix's free check tries the problem you describe on your live app: tell us what broke, and our AI agent tries it and sends you a screenshot. If you want it fixed, it finds the cause, fixes it in your code and re-checks your live app. The free check never changes your app. Check my app free
Our AI agent finds the cause, fixes it in your code for $79, paid up front, and re-checks your live app. If we can't complete your re-check, you get your money back.
Cause 5: The page asks for the user before the session has loaded
In a browser app, the client restores the session from storage when the page loads. Code that runs at once, before that finishes, sees no session.
How to fix it:
- Listen with onAuthStateChange and wait for the INITIAL_SESSION event before you call any method that needs a user.
- Show a loading state until then.
- Keep the callback short. Run follow-up Supabase calls outside it, for example in a setTimeout or a separate effect.
supabase.auth.onAuthStateChange((event, session) => {
if (event === 'INITIAL_SESSION') {
setSession(session) // now safe to decide signed-in or not
setLoading(false)
}
})
Related guides
- Lovable login loop: why you keep returning to sign-in
- Lovable sign-in works in preview but fails when published
- Supabase auth cookie lost after login on Next.js in production
- Invalid Refresh Token: Refresh Token Not Found
Sources (official documentation)
- Supabase: getUser()
- Supabase: getSession()
- Supabase: signOut()
- Supabase: onAuthStateChange()
- Supabase: Sessions
- Supabase: PKCE flow
- Supabase: Password-based auth
- Supabase: Auth error codes
- Supabase: Server-side auth for Next.js
- auth-js: src/lib/errors.ts
- auth-js: src/GoTrueClient.ts
- supabase/supabase issue #25827 (report only, no cause given)
Last checked: 16 November 2026
VibeFix is independent. Supabase is a trademark of its owner.
Want it fixed?
Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.
It starts with a free check that confirms the problem on your live app, no account needed.
More guides · Shopify store accessibility · About · Your privacy choices