Skip to content

feat: bump storage version, and expose StorageClientOptions #1500

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

Merged
merged 2 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@supabase/node-fetch": "2.6.15",
"@supabase/postgrest-js": "1.19.4",
"@supabase/realtime-js": "2.11.15",
"@supabase/storage-js": "2.7.1"
"@supabase/storage-js": "^2.10.4"
},
"devDependencies": {
"@sebbo2002/semantic-release-jsr": "^1.0.0",
Expand Down
19 changes: 12 additions & 7 deletions src/SupabaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export default class SupabaseClient<
*/
auth: SupabaseAuthClient
realtime: RealtimeClient
/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
storage: SupabaseStorageClient

protected realtimeUrl: URL
protected authUrl: URL
Expand All @@ -64,6 +68,7 @@ export default class SupabaseClient<
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
* @param options.realtime Options passed along to realtime-js constructor.
* @param options.storage Options passed along to the storage-js constructor.
* @param options.global.fetch A custom fetch implementation.
* @param options.global.headers Any additional headers to send with each network request.
*/
Expand Down Expand Up @@ -130,6 +135,13 @@ export default class SupabaseClient<
fetch: this.fetch,
})

this.storage = new SupabaseStorageClient(
this.storageUrl.href,
this.headers,
this.fetch,
options?.storage
)

if (!settings.accessToken) {
this._listenForAuthEvents()
}
Expand All @@ -145,13 +157,6 @@ export default class SupabaseClient<
})
}

/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
get storage(): SupabaseStorageClient {
return new SupabaseStorageClient(this.storageUrl.href, this.headers, this.fetch)
}

// NOTE: signatures must be kept in sync with PostgrestClient.from
from<
TableName extends string & keyof Schema['Tables'],
Expand Down
1 change: 1 addition & 0 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function applySettingDefaults<
...DEFAULT_REALTIME_OPTIONS,
...realtimeOptions,
},
storage: {},
global: {
...DEFAULT_GLOBAL_OPTIONS,
...globalOptions,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AuthClient } from '@supabase/auth-js'
import { RealtimeClientOptions } from '@supabase/realtime-js'
import { PostgrestError } from '@supabase/postgrest-js'
import { StorageClientOptions } from '@supabase/storage-js/dist/module/StorageClient'

type AuthClientOptions = ConstructorParameters<typeof AuthClient>[0]

Expand Down Expand Up @@ -56,6 +57,7 @@ export type SupabaseClientOptions<SchemaName> = {
* Options passed to the realtime-js instance
*/
realtime?: RealtimeClientOptions
storage?: StorageClientOptions
global?: {
/**
* A custom `fetch` implementation.
Expand Down
Loading