# RealtimeClient | @supabase/supabase-js
Documentation for @supabase/supabase-js

### Hierarchy

- RealtimeClient

## Index

### Constructors

- constructor

### Properties

- _appendParams
- _flushSendBuffer
- _onConnClose
- _onConnError
- _onConnOpen
- _sendHeartbeat
- _triggerChanError
- accessToken
- channels
- conn
- decode
- encode
- endPoint
- headers
- heartbeatIntervalMs
- heartbeatTimer
- logger
- longpollerTimeout
- params
- pendingHeartbeatRef
- reconnectAfterMs
- reconnectTimer
- ref
- sendBuffer
- serializer
- stateChangeCallbacks
- timeout
- transport

### Methods

- channel
- connect
- connectionState
- disconnect
- endPointURL
- isConnected
- leaveOpenTopic
- log
- makeRef
- onClose
- onConnMessage
- onError
- onMessage
- onOpen
- push
- remove
- setAuth

## Constructors

### constructor

- new RealtimeClient(endPoint: string, options?: RealtimeClientOptions ): RealtimeClient

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:77

  Initializes the Socket.

  #### Parameters

  - ##### endPoint: string

    The string WebSocket endpoint, ie, "ws://example.com/socket", "wss://example.com", "/socket" (inherited host & protocol)

  - ##### Optional options: RealtimeClientOptions

  #### Returns RealtimeClient

## Properties

### Private _appendParams

_appendParams: any

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:180

### Private _flushSendBuffer

_flushSendBuffer: any

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:181

### Private _onConnClose

_onConnClose: any

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:177

### Private _onConnError

_onConnError: any

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:178

### Private _onConnOpen

_onConnOpen: any

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:176

### Private _sendHeartbeat

_sendHeartbeat: any

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:182

### Private _triggerChanError

_triggerChanError: any

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:179

### accessToken

accessToken: null | string

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:32

### channels

channels: RealtimeSubscription []

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:33

### conn

conn: null | WebSocket

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:53

### decode

decode: Function

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:51

### encode

encode: Function

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:50

### endPoint

endPoint: string

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:34

### Optional headers

headers?: {}

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:35

#### Type declaration

- ##### [key: string]: string

### heartbeatIntervalMs

heartbeatIntervalMs: number

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:43

### heartbeatTimer

heartbeatTimer: undefined | Timer

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:45

### logger

logger: Function

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:49

### longpollerTimeout

longpollerTimeout: number

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:44

### Optional params

params?: {}

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:38

#### Type declaration

- ##### [key: string]: string

### pendingHeartbeatRef

pendingHeartbeatRef: null | string

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:46

### reconnectAfterMs

reconnectAfterMs: Function

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:52

### reconnectTimer

reconnectTimer: default

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:48

### ref

ref: number

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:47

### sendBuffer

sendBuffer: Function[]

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:54

### serializer

serializer: default

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:55

### stateChangeCallbacks

stateChangeCallbacks: { close: Function[]; error: Function[]; message: Function[]; open: Function[] }

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:56

#### Type declaration

- ##### close: Function[]

- ##### error: Function[]

- ##### message: Function[]

- ##### open: Function[]

### timeout

timeout: number

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:41

### transport

transport: any

- Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:42

## Methods

### channel

- channel(topic: string, chanParams?: ChannelParams): RealtimeSubscription

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:148

  #### Parameters

  - ##### topic: string

  - ##### Optional chanParams: ChannelParams

  #### Returns RealtimeSubscription

### connect

- connect(): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:81

  Connects the socket, unless already connected.

  #### Returns void

### connectionState

- connectionState(): CONNECTION_STATE

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:137

  Returns the current state of the socket.

  #### Returns CONNECTION_STATE

### disconnect

- disconnect(code?: number, reason?: string): Promise<{ data: boolean; error: null | Error }>

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:88

  Disconnects the socket.

  #### Parameters

  - ##### Optional code: number

    A numeric status code to send on disconnect.

  - ##### Optional reason: string

    A custom reason for the disconnect.

  #### Returns Promise<{ data: boolean; error: null | Error }>

### endPointURL

- endPointURL(): string

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:161

  Returns the URL of the websocket.

  #### Returns string

### isConnected

- isConnected(): boolean

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:141

  Retuns `true` is the connection is open.

  #### Returns boolean

### leaveOpenTopic

- leaveOpenTopic(topic: string): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:175

  Unsubscribe from channels with the specified topic.

  #### Parameters

  - ##### topic: string

  #### Returns void

### log

- log(kind: string, msg: string, data?: any): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:97

  Logs the message.

  For customized logging, `this.logger` can be overriden.

  #### Parameters

  - ##### kind: string

  - ##### msg: string

  - ##### Optional data: any

  #### Returns void

### makeRef

- makeRef(): string

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:165

  Return the next message ref, accounting for overflows

  #### Returns string

### onClose

- onClose(callback: Function): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:115

  Registers a callback for connection state change events.

  example

    socket.onOpen(() => console.log("Socket closed."))

  #### Parameters

  - ##### callback: Function

    A function to be called when the event occurs.

  #### Returns void

### onConnMessage

- onConnMessage(rawMessage: { data: any }): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:155

  #### Parameters

  - ##### rawMessage: { data: any }

    - ##### data: any

  #### Returns void

### onError

- onError(callback: Function): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:124

  Registers a callback for connection state change events.

  example

    socket.onOpen((error) => console.log("An error occurred"))

  #### Parameters

  - ##### callback: Function

    A function to be called when the event occurs.

  #### Returns void

### onMessage

- onMessage(callback: Function): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:133

  Calls a function any time a message is received.

  example

    socket.onMessage((message) => console.log(message))

  #### Parameters

  - ##### callback: Function

    A function to be called when the event occurs.

  #### Returns void

### onOpen

- onOpen(callback: Function): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:106

  Registers a callback for connection state change event.

  example

    socket.onOpen(() => console.log("Socket opened."))

  #### Parameters

  - ##### callback: Function

    A function to be called when the event occurs.

  #### Returns void

### push

- push(data: Message): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:154

  Push out a message if the socket is connected.

  If the socket is not connected, the message gets enqueued within a local buffer, and sent out when a connection is next established.

  #### Parameters

  - ##### data: Message

  #### Returns void

### remove

- remove(channel: RealtimeSubscription ): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:147

  Removes a subscription from the socket.

  #### Parameters

  - ##### channel: RealtimeSubscription

    An open subscription.

  #### Returns void

### setAuth

- setAuth(token: null | string): void

- - Defined in node_modules/@supabase/realtime-js/dist/module/RealtimeClient.d.ts:171

  Sets the JWT access token used for channel subscription authorization and Realtime RLS.

  #### Parameters

  - ##### token: null | string

    A JWT string.

  #### Returns void

Generated using TypeDoc