Skip to content

fix(types): export type utils for ssr use #1491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: next
Choose a base branch
from

Conversation

avallete
Copy link
Member

@avallete avallete commented Jul 10, 2025

What kind of change does this PR introduce?

2.50.4 introduced a breaking change into SupabaseClient types templating parameter which caused an issue when upgrading and using @supabase/ssr since it re-use the same typing logic for it's own createXXXClient functions.

This is an attempt to:

  1. Add a smoking test within supabase-js to be notified of this kind of types breakage when they occurs before releasing.
  2. Add new utils so we can move some of the typing logic from @supabase/ssr to @supabase/supabase-js

BREAKING CHANGES:

  • SupabaseClient now have options as second parameter instead of SchemaName which will require some migration if using the SupabaseClient type directly:
// from
type PublicClient = SupabaseClient<Database, 'public'>
// to
type PublicClient = SupabaseClient<Database, { PostgrestVersion: '12' | '13' }, 'public'>
// or if your introspected Database has the `__InternalSupabase` schema:
type PublicClient = SupabaseClient<Database, Database['__InternalSupabase'], 'public'>

Why this change ?

It allows the typing of the client to prepare an takes into account different postgrest version, and accounting for the slight differences in behavior between the two versions at typing level.

@coveralls
Copy link

coveralls commented Jul 10, 2025

Pull Request Test Coverage Report for Build 16217719297

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 81.14%

Totals Coverage Status
Change from base Build 16197271777: 0.0%
Covered Lines: 118
Relevant Lines: 135

💛 - Coveralls

@@ -5,7 +5,8 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "playwright test",
"test": "npm run test:types && playwright test",
"test:types": "npx tsd --files tests/types/*.test-d.ts",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduce basics typing tests for the @supabase/ssr context. Since it depends of supabase-js as peer deps, it'll help detect uncaught breaking change that would break compatibility between ssr and supabase-js previous verison.

@avallete avallete changed the title Fix/export type utils for ssr use fix(types): export type utils for ssr use Jul 11, 2025
@avallete avallete marked this pull request as ready for review July 11, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants