Skip to content
Aurabase Logo
aurabase

JavaScript SDK: realtime reference

Every method of the realtime service and of channels, with its signature.

Reference6 min readLevel reference

RealtimeService#

PropertyDescription
get connectionState(): ConnectionStateCurrent connection state.
get isConnected(): booleanWhether the WebSocket is currently connected.
MethodDescription
onStateChange(callback: (state: ConnectionState) => void): () => voidListen for connection state changes.
onError(callback: (err: RealtimeConnectionError) => void): () => voidListen for realtime connection transport errors.
connect(): voidEnsure the WebSocket connection is open.
refreshToken(token: string): voidRefresh the JWT token on an existing connection (no disconnect).
setAuth(token?: string): voidExplicitly defines/refreshes the token used for authorization of private and broadcast channels (parity @supabase/realtime-js setAuth).
httpBroadcast(channel: string, event: string, payload?: Record<string, unknown>, options?: HttpBroadcastOptions): Promise<AuraResponse<null>>Sends a broadcast via HTTP (REST), without an open WebSocket connection (parity @supabase/realtime-js).
setAutoReconnect(enabled: boolean, maxAttempts?: number): voidEnable/disable auto-reconnect (enabled by default).
disconnect(): voidDisconnect the WebSocket and clean up all channels.
channel(name: string, options?: ChannelConfig): AuraChannelCreate or retrieve a channel by name.
removeChannel(channel: string | AuraChannel): voidRemove a channel by name or by AuraChannel instance.
getChannels(): AuraChannel[]List active channels.
removeAllChannels(): voidRemove all channels and subscriptions.

AuraChannel#

A realtime channel with Supabase-compatible chainable API.

PropertyDescription
readonly name: stringChannel name as passed to realtime.channel(name).
get fullName(): stringFull channel name with project prefix (for server protocol)
get isSubscribed(): booleanWhether this channel has been subscribed.
MethodDescription
on<TRow = Record<string, unknown>>(type: 'postgres_changes', filter: PostgresChangesFilter & { event: 'INSERT'; }, callback: (payload: RealtimePostgresInsertPayload<TRow>) => void): AuraChannelSubscription
on<TRow = Record<string, unknown>>(type: 'postgres_changes', filter: PostgresChangesFilter & { event: 'UPDATE'; }, callback: (payload: RealtimePostgresUpdatePayload<TRow>) => void): AuraChannelSubscription
on<TRow = Record<string, unknown>>(type: 'postgres_changes', filter: PostgresChangesFilter & { event: 'DELETE'; }, callback: (payload: RealtimePostgresDeletePayload<TRow>) => void): AuraChannelSubscription
on<TRow = Record<string, unknown>>(type: 'postgres_changes', filter: PostgresChangesFilter, callback: (payload: RealtimePostgresChangesPayload<TRow>) => void): AuraChannelSubscription
on<TPayload = Record<string, unknown>>(type: 'broadcast', filter: BroadcastFilter, callback: (payload: RealtimeBroadcastEvent<TPayload>) => void): AuraChannelSubscription
on(type: 'presence', filter: PresenceFilter, callback: (payload: PresenceState | RealtimeEvent | Record<string, unknown>) => void): AuraChannelSubscription
Registers a listener for PostgreSQL (CDC) events with INSERT filtering.
off(type?: RealtimeListenType, filter?: PostgresChangesFilter | BroadcastFilter | PresenceFilter, callback?: (payload: unknown) => void): thisRemoves one or more listeners from the channel without closing the channel or cutting the WebSocket.
subscribe(callback?: SubscribeCallback, timeoutMs?: number): thisSubscribe to the channel.
unsubscribe(): Promise<'ok'>Unsubscribe from the channel.
send(message: BroadcastPayload): Promise<BroadcastSendStatus>Sends a broadcast message on the channel.
track(state: Record<string, unknown>): Promise<'ok' | 'error'>Track presence state for this client.
untrack(): Promise<'ok' | 'error'>Stop tracking presence.
presenceState(): PresenceStateGet the current presence state for this channel.
Generated page

This page is generated from the type declarations and comments of the SDK, so it cannot drift from the published code. For worked examples, read the guides.

@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Report a problem