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
garyaustin
garyaustin2y ago
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.
OMGairbnbs
OMGairbnbsOP2y ago
so i should use that function only in one file and then share it through cookies?
garyaustin
garyaustin2y ago
If you are doing server side stuff you should look at auth-helpers/ssr as it handles all the coordination.
OMGairbnbs
OMGairbnbsOP2y ago
OK. But is there any way to share it through the entire app or I have to call it in each file?
garyaustin
garyaustin2y ago
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.
garyaustin
garyaustin2y ago
Yes.
OMGairbnbs
OMGairbnbsOP2y ago
Thank you so much!

Did you find this page helpful?