-
Notifications
You must be signed in to change notification settings - Fork 482
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
When using the Supabase server client (from @supabase/ssr
) to call signIn
or signOut
inside a Next.js server action
, the auth state changes are not detected on the browser client (createBrowserClient()
).
Specifically, onAuthStateChange()
on the browser client does not fire when the sign-in or sign-out is done from a server action.
This leads to an inconsistent auth state in the frontend after using server-side auth methods.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Set up Supabase in a Next.js app using both
createServerClient()
andcreateBrowserClient()
- Set up
onAuthStateChange()
in a layout or component using the browser client. - Trigger
signIn()
orsignOut()
using a server action via the server client. - Notice that the browser does not detect any change in auth state.
Expected behavior
Calling signIn()
or signOut()
on the server should also update the browser-side auth state or trigger onAuthStateChange()
accordingly, assuming the cookies are properly shared.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- OS: [e.g. macOS, Windows]
- Browser (if applies) [e.g. chrome, safari]
- Version of supabase-js: [e.g. 6.0.2]
- Version of Node.js: [e.g. 10.10.0]
Additional context
This behavior breaks real-time auth-dependent UI updates and makes sign-in/sign-out UX inconsistent.