Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseβ€’14mo agoβ€’
13 replies
Elliott

Invalid Refresh Token: Already Used: SSR NextJS

I have used the SSR Auth Guide for setting up auth with NextJS. https://supabase.com/docs/guides/auth/server-side/nextjs?queryGroups=router&router=app

I am seeing that inconsistently my token (set in the browser as a cookie) is becoming invalid. Sometimes I am even seeing the
Invalid Refresh Token: Already Used
Invalid Refresh Token: Already Used
message. I don't have anything custom or different about my flow for auth. I have done everything in the guide to a T. Based on searching around I believe that there is a potential problem with the browser client in that it's trying to potentially refresh the token even though the server and middleware already achieve that. I am still testing out a few things.


A weird anecdote is that it only happens on one page/component and I am making probably 10 requests to supabase back to back. My thoughts are it's one of two things:

1. I am calling the DB too much that it's freaking out the auth system because a token is out of date or in a weird state when I call (and I need to optimize this...)
2. Something is happening with the token being set in the cookies that isn't playing nicely with browser side code.


Thoughts? Happy to share some code if it helps but likely it's just gonna be the guide code.
Setting up Server-Side Auth for Next.js | Supabase Docs
Setting up Server-Side Auth for Next.js | Supabase Docs
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

@supabase/ssr: (NextJS) Invalid Refresh Token: Session Expired (someone please assist)
SupabaseSSupabase / help-and-questions
13mo ago
Invalid Refresh Token
SupabaseSSupabase / help-and-questions
4y ago
Invalid Refresh Token: Refresh Token Not found
SupabaseSSupabase / help-and-questions
2y ago
[ Error [ AuthApiError ]: Invalid Refresh Token: Refresh Token Not Found ]
SupabaseSSupabase / help-and-questions
14mo ago