Warning : Multiple GoTrueClient instances detected in the same browser context
Hello,
I use Supabase in nextjs with next-auth and got the"Multiple GoTrueClient instances..." warning in the console when i want to pass the next-auth bearer token to the supabase client. I have tried multiple ways to implement createClient including context at the root, i checked on github repos, but i'm still stuck...
1 - Singleton Approach. No warning but can't pass the bearer token
"
const client = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY);
const supabase = () => client;
export default supabase;
"
2 - Classic approach. It works but many warnings in the console
"
export const supabaseClient = async (supabaseAccessToken) => {
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
{
global: {
headers: { Authorization:
},
}
);
return supabase;
};
"
Ideally i would like to fetch the token from useSession directly in my supabase client file so that i don't have to pass it as params.
If there is no solution, will this affect performances ? How can i hide this warning ?
Thanks for your help
I use Supabase in nextjs with next-auth and got the"Multiple GoTrueClient instances..." warning in the console when i want to pass the next-auth bearer token to the supabase client. I have tried multiple ways to implement createClient including context at the root, i checked on github repos, but i'm still stuck...
1 - Singleton Approach. No warning but can't pass the bearer token
"
const client = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY);
const supabase = () => client;
export default supabase;
"
2 - Classic approach. It works but many warnings in the console
"
export const supabaseClient = async (supabaseAccessToken) => {
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
{
global: {
headers: { Authorization:
Bearer ${supabaseAccessToken} },},
}
);
return supabase;
};
"
Ideally i would like to fetch the token from useSession directly in my supabase client file so that i don't have to pass it as params.
If there is no solution, will this affect performances ? How can i hide this warning ?
Thanks for your help