Skip to content

feat!: add supabaseOptions and refactor client creation to options objects - #19

Merged
kallebysantos merged 2 commits into
mainfrom
tomas/func-529-add-support-of-for-supabase-client-options
Mar 26, 2026
Merged

feat!: add supabaseOptions and refactor client creation to options objects#19
kallebysantos merged 2 commits into
mainfrom
tomas/func-529-add-support-of-for-supabase-client-options

Conversation

@tomaspozo

@tomaspozo tomaspozo commented Mar 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds supabaseOptions?: SupabaseClientOptions<string> to WithSupabaseConfig, allowing users to customize internal createClient() calls (e.g., db.schema, custom fetch, realtime config)
  • Options flow through to both the RLS-scoped client and the admin client
  • Security-critical auth settings (persistSession, autoRefreshToken, detectSessionInUrl) and the Authorization header are always force-overwritten

@linear

linear Bot commented Mar 25, 2026

Copy link
Copy Markdown
FUNC-529 Add support of for supabase client options

We should allow users to customize the way the way the internal clients are initialized:

withSupabase({allow:"always", supabaseOptions: {schema: "api"}})

and we extend the interface like this, and pass down

export interface WithSupabaseConfig {
...
supabaseOptions: SupabaseClientOptions<SchemaName>
}

@tomaspozo
tomaspozo force-pushed the tomas/func-529-add-support-of-for-supabase-client-options branch from 377d229 to ac099ac Compare March 25, 2026 19:29
…ization

Allow users to pass `SupabaseClientOptions` through to the internal
`createClient` calls, enabling custom schemas, fetch, and realtime config
while security-critical auth settings remain force-overwritten.
@tomaspozo
tomaspozo force-pushed the tomas/func-529-add-support-of-for-supabase-client-options branch from ac099ac to 629168d Compare March 25, 2026 20:44
@tomaspozo tomaspozo changed the title feat: add supabaseOptions to WithSupabaseConfig feat!: add supabaseOptions and refactor client creation to options objects Mar 25, 2026
@tomaspozo
tomaspozo marked this pull request as ready for review March 25, 2026 20:53
Copilot AI review requested due to automatic review settings March 25, 2026 20:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a supabaseOptions escape hatch to customize the internal Supabase client creation while refactoring createContextClient / createAdminClient to accept options objects, and wiring the options through createSupabaseContext / withSupabase.

Changes:

  • Add supabaseOptions?: SupabaseClientOptions<string> to WithSupabaseConfig and introduce ClientAuth, CreateContextClientOptions, and CreateAdminClientOptions types.
  • Refactor createContextClient / createAdminClient to accept options objects and merge forwarded supabaseOptions.
  • Update and extend tests to cover the new options-object APIs and basic supabaseOptions plumbing.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/types.ts Adds new public config/options types and the supabaseOptions config field.
src/index.ts Re-exports the newly introduced types from the main entrypoint.
src/create-supabase-context.ts Threads supabaseOptions into both context and admin client creation via options objects.
src/create-supabase-context.test.ts Adds a basic test for supabaseOptions plumbing through createSupabaseContext.
src/core/index.ts Re-exports the new types from the ./core entrypoint.
src/core/create-context-client.ts Refactors to options object and merges forwarded supabaseOptions into createClient() options.
src/core/create-context-client.test.ts Updates for options-object signature and adds basic supabaseOptions tests.
src/core/create-admin-client.ts Refactors to options object and merges forwarded supabaseOptions into createClient() options.
src/core/create-admin-client.test.ts Updates for options-object signature and adds a basic supabaseOptions test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/create-context-client.ts
Comment thread src/core/create-admin-client.ts
Comment thread src/create-supabase-context.test.ts
Comment thread src/core/create-context-client.test.ts
Comment thread src/core/create-admin-client.test.ts
@tomaspozo
tomaspozo requested a review from kallebysantos March 25, 2026 21:00
User-provided supabaseOptions.global.headers could include Authorization
or apikey, bypassing verified credentials. Strip both before spreading
user headers into the client options.
detectSessionInUrl: false,
},
})
} as Parameters<typeof createClient<Database>>[2])

@kallebysantos kallebysantos Mar 26, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe this ensures TS sync with database main type with the scoped selected schema 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Update: It doesn't sync types

@kallebysantos kallebysantos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me!!
Just not really sure if the final Typescript will scope the selected schema, since its expects narrow types and passing down the SchemaName.


Update: Its not scoping to selected schema

Details
Screen.Recording.2026-03-26.at.12.20.41.mov

@kallebysantos
kallebysantos merged commit 5a10099 into main Mar 26, 2026
2 of 3 checks passed
@kallebysantos
kallebysantos deleted the tomas/func-529-add-support-of-for-supabase-client-options branch March 26, 2026 11:54
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.

3 participants