diff --git a/src/createBrowserClient.ts b/src/createBrowserClient.ts index a7ac3bb..536efd0 100644 --- a/src/createBrowserClient.ts +++ b/src/createBrowserClient.ts @@ -118,6 +118,8 @@ export function createBrowserClient< false, ); + const storageKey = options?.auth?.storageKey || options?.cookieOptions?.name; + const client = createClient( supabaseUrl, supabaseKey, @@ -132,9 +134,7 @@ export function createBrowserClient< }, auth: { ...options?.auth, - ...(options?.cookieOptions?.name - ? { storageKey: options.cookieOptions.name } - : null), + ...(storageKey ? { storageKey } : null), flowType: "pkce", autoRefreshToken: isBrowser(), detectSessionInUrl: isBrowser(), diff --git a/src/createServerClient.ts b/src/createServerClient.ts index c4f3d6a..6aa7e2f 100644 --- a/src/createServerClient.ts +++ b/src/createServerClient.ts @@ -149,6 +149,7 @@ export function createServerClient< }, true, ); + const storageKey = options?.auth?.storageKey || options?.cookieOptions?.name; const client = createClient( supabaseUrl, @@ -163,9 +164,7 @@ export function createServerClient< }, }, auth: { - ...(options?.cookieOptions?.name - ? { storageKey: options.cookieOptions.name } - : null), + ...(storageKey ? { storageKey } : null), ...options?.auth, flowType: "pkce", autoRefreshToken: false,