Multiple GoTrueClient error
GoTrueClient.js:58 Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.
const supabase = createClient<Database>(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!)
I'm using this on several files, can that be the issue? Anyone knows how can i fix it?
Thanks
8 Replies
It is not an error but a warning. If you have multiple clients being created and they use the same local storage key, they will share the user session. So it depends on what you are doing with multiple clients.
so i should use that function only in one file and then share it through cookies?
If you are doing server side stuff you should look at auth-helpers/ssr as it handles all the coordination.
OK. But is there any way to share it through the entire app or I have to call it in each file?
Server side you normally call auth-helpers clients each time, they share a cookie. CreateClient() on a server does not make any Supabase server calls, just sets up an object in memory.
https://supabase.com/docs/guides/auth/server-side/creating-a-client?environment=server-component
This what you are talking about. right?
Creating a Supabase client for SSR | Supabase Docs
Configure Supabase client to use Cookies
Yes.
Thank you so much!