SupabaseS
Supabase12mo ago
IPJT

Connect to 2 different Supabase projects from the same user

Hi there,
I'm currently using createBrowserClient from @supabase/ssr to create a db-client to be used in the browser-environment.

As seen in the src-code the createBrowserClient is merely a wrapper around createClient from @supabase/supabase-js that returns a cached SupabaseClient-instance making me not having to worry about calling createBrowserClient 1000 times in my app. Great!

However, now i want to create a new client connecting to a different Supabase instance. This client is only to be used in the browser environment. If I call createBrowserClient with a different supabaseUrl and supabaseKey it will just returned the cached version (first of the two DBs being connected to).

There is a "isSingleton" prop I can pass to createBrowserClient to solve this issue. However, that would mean my first connection would use a singleton-pattern whereas my second doesn't (additionally it logs the warning shown in the screenshot). Ideally both clients would be cached.

Thanks in advance.
Ian
image.png
Was this page helpful?