supabase icon indicating copy to clipboard operation
supabase copied to clipboard

createServerClient deprecation incongruence

Open voltuer opened this issue 2 months ago β€’ 1 comments

Bug report

  • [x] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When folllowing the documentation for the SSR client, TypeScript complains about deprecation.

The signature '(supabaseUrl: string, supabaseKey: string, options: SupabaseClientOptions<"public"> & { cookieOptions?: CookieOptionsWithName | undefined; cookies: CookieMethodsServerDeprecated; cookieEncoding?: "raw" | ... 1 more ... | undefined; }): SupabaseClient<...>' of 'createServerClient' is deprecated.ts(6387)
createServerClient.d.ts(4, 4): The declaration was marked as deprecated here.

Expected behavior

I expect the type definitions on the library to be congruent with the official documentation

System information

  • OS: MacOS
  • Version of supabase-js: latest
  • Version of supabase-ssr: latest
  • Version of Node.js: 24.11

Additional context

It also seems that you're deprecating cookieOptions which is insane since we need to be able to specify the cookie name.

voltuer avatar Dec 05 '25 23:12 voltuer

Hi @voltuer πŸ’š Its seems a bit confusing but your LSP is probably handling it wrong πŸ˜…

What happened? The createServerClient() has changed its signature and a override method was introduced, so there's actually 2 versions of this function:

// @deprecated Please specify `getAll` and `setAll` cookie methods ...
export declare function createServerClient({
    cookieOptions?: CookieOptionsWithName,
    cookies: CookieMethodsServerDeprecated, // <--- This one changed
    cookieEncoding?: "raw" | "base64url"
})

// The new one:
export declare function createServerClient({
    cookieOptions?: CookieOptionsWithName,
    cookies: CookieMethodsServer, // <--- New type
    cookieEncoding?: "raw" | "base64url",
})

How to fix? You need to make sure that your code is using the new version of cookies object:

  const supabase = createServerClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
    {
      cookies: {
-        get(name) {
+        getAll() {
          return request.cookies.getAll();
        },
-       set(name) {
+       setAll(cookiesToSet) {
            // ...
         }
    }

Try to restart your IDE, as well clean your node_modules folder, maybe delete your pnpm-lock.yaml file too

Neovim

https://github.com/user-attachments/assets/aa97e0f5-ca7b-4f36-9c53-b484ba5efa49

like you can see, all errors disappear after changing the cookies object as well the inline docs changed

kallebysantos avatar Dec 06 '25 01:12 kallebysantos

Try to restart your IDE, as well clean your node_modules folder, maybe delete your pnpm-lock.yaml file too

I did all that and the warning just won't go away. I don't get it.

CoolOppo avatar Dec 16 '25 11:12 CoolOppo

Hi @CoolOppo πŸ’š May you check if your code is using the older method overload? Like I did suggest in my previous comment?

kallebysantos avatar Dec 16 '25 14:12 kallebysantos

@CoolOppo I can affirm that the issue has not been resolved on my end as well, and like @kallebysantos pointed out, there're two versions of the createServerClient function existing, and one seems to be overloading the other in a not so great way, and there's no way to tell whcih method my code is using.

We would love if this could be looked at, thank you @kallebysantos πŸ™πŸΎ

Olulanke-Mainasara avatar Dec 17 '25 18:12 Olulanke-Mainasara

Hi @CoolOppo @Olulanke-Mainasara I can confirm the warning is reproducible, & @kallebysantos's suggestion fixes it!

If the issue still persists, try:
  • Delete node_modules & reinstall
  • Restart TS server

7ttp avatar Dec 17 '25 20:12 7ttp

Thank you very much @7ttp and @kallebysantos πŸ™πŸΎ

And for anyone still having the issue, even after following the suggestions, all you need to do is just update the @supabase/ssr package, and the incongruence would be resolvedπŸ’―

Olulanke-Mainasara avatar Dec 18 '25 11:12 Olulanke-Mainasara