Skip to content

Type Inference Broken with @supabase/ssr@0.5.2 + @supabase/supabase-js@2.74.0 #1738

@DuncanLHS

Description

@DuncanLHS

Describe the bug

After upgrading to @supabase/supabase-js@2.74.0 , type inference completely breaks when using createServerClient from @supabase/ssr@0.5.2. All query results are typed as never, making the library unusable with TypeScript.

Note: The issue does NOT occur with the regular createClient from @supabase/supabase-js - only with createServerClient from @supabase/ssr.

Library affected

supabase-js

Reproduction

No response

Steps to reproduce

Environment:

  • @supabase/supabase-js: 2.74.0
  • @supabase/ssr: 0.5.2
  • supabase cli: 2.48.3
  • TypeScript: 5.9.2
  • Node: 22.12.0

Minimal reproduction:

import { createServerClient } from "@supabase/ssr"
import type { Database } from "./database.types" // Generated with `supabase gen types typescript`

const supabase = createServerClient<Database>(
  process.env.SUPABASE_URL!,
  process.env.SUPABASE_ANON_KEY!,
  {
    cookies: {
      getAll() { return [] },
      setAll() { /* no-op */ },
    },
  }
)

async function example() {
  // TypeScript error: All operations return 'never' type
  const { data } = await supabase
    .from("my_table")
    .select("id, name")
    .single()
  
  // Error: Property 'id' does not exist on type 'never'
  console.log(data.id)
  
  // Error: Argument of type '{ name: string }' is not assignable to parameter of type 'never'
  await supabase.from("my_table").insert({ name: "test" })
  
  // Error: Argument of type '{ arg: string }' is not assignable to parameter of type 'never'  
  await supabase.rpc("my_function", { arg: "value" })
}

TypeScript errors:

node_modules/@supabase/ssr/dist/main/createServerClient.d.ts:13:30 - error TS2344: 
Type 'SchemaName' does not satisfy the constraint 
'{ PostgrestVersion: string; } | (string & Exclude<keyof Database, "__InternalSupabase">)'.

Additionally, all query methods show:

  • .from() calls: PostgrestFilterBuilder<..., never, never, ...>
  • .insert() expects parameter of type never
  • .rpc() expects parameter of type never
  • Result data is typed as never

Additional context

Workaround: Downgrading to @supabase/supabase-js@2.58.0 resolves the issue:

npm install @supabase/supabase-js@2.58.0 --save

Observation:

  • The issue appears to be a compatibility problem between @supabase/ssr@0.5.2 (released August 2025) and the type changes in supabase-js@2.74.0
  • The TypeScript error mentions Exclude<keyof Database, "__InternalSupabase"> which suggests v2.74.0 expects a __InternalSupabase key in the Database type that wasn't required before
  • The CLI-generated types from supabase gen types typescript do not include an __InternalSupabase key
  • The newer @supabase/ssr@0.7.0 (released August 22, 2025) was supposed to handle this according to PR #123, but upgrading to it still fails with similar type errors

Related:

It appears PR #1537 may not have been included in the v2.74.0 release, despite being merged on August 21, 2025.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
    Memory: 13.92 GB / 31.64 GB
  Binaries:
    Node: 22.12.0 - C:\Users\d.band\AppData\Local\Volta\tools\image\node\22.12.0\node.EXE
    Yarn: 4.6.0 - C:\Users\d.band\AppData\Local\Volta\tools\image\yarn\4.6.0\bin\yarn.CMD
    npm: 10.9.0 - C:\Users\d.band\AppData\Local\Volta\tools\image\node\22.12.0\npm.CMD
    pnpm: 10.12.1 - C:\Program Files\Volta\pnpm.EXE
    Deno: 1.43.6 - C:\Users\d.band\.deno\bin\deno.EXE
  Browsers:
    Chrome: 141.0.7390.55
    Edge: Chromium (141.0.3537.57)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @supabase/ssr: ^0.5.2 => 0.5.2
    @supabase/supabase-js: ^2.74.0 => 2.74.0

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsupabase-jsRelated to the supabase-js library.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions