@@ -4,7 +4,7 @@ import { SupabaseAuthClient } from './lib/SupabaseAuthClient'
44import { SupabaseQueryBuilder } from './lib/SupabaseQueryBuilder'
55import { SupabaseStorageClient } from '@supabase/storage-js'
66import { PostgrestClient } from '@supabase/postgrest-js'
7- import { RealtimeClient , RealtimeSubscription } from '@supabase/realtime-js'
7+ import { RealtimeClient , RealtimeSubscription , RealtimeClientOptions } from '@supabase/realtime-js'
88
99const DEFAULT_OPTIONS = {
1010 schema : 'public' ,
@@ -42,6 +42,7 @@ export default class SupabaseClient {
4242 * @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
4343 * @param options.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
4444 * @param options.headers Any additional headers to send with each network request.
45+ * @param options.realtime Options passed along to realtime-js constructor.
4546 */
4647 constructor (
4748 protected supabaseUrl : string ,
@@ -59,7 +60,7 @@ export default class SupabaseClient {
5960 this . schema = settings . schema
6061
6162 this . auth = this . _initSupabaseAuthClient ( settings )
62- this . realtime = this . _initRealtimeClient ( )
63+ this . realtime = this . _initRealtimeClient ( settings . realtime )
6364
6465 // In the future we might allow the user to pass in a logger to receive these events.
6566 // this.realtime.onOpen(() => console.log('OPEN'))
@@ -154,9 +155,10 @@ export default class SupabaseClient {
154155 } )
155156 }
156157
157- private _initRealtimeClient ( ) {
158+ private _initRealtimeClient ( options ?: RealtimeClientOptions ) {
158159 return new RealtimeClient ( this . realtimeUrl , {
159- params : { apikey : this . supabaseKey } ,
160+ ...options ,
161+ params : { ...options ?. params , apikey : this . supabaseKey } ,
160162 } )
161163 }
162164
0 commit comments