Skip to main content
zerotal

Documentation


Documentation / zerotal / client / SocketOptions

Interface: SocketOptions

Defined in: packages/client/src/Socket.ts:48

Properties

url?

optional url?: string

Defined in: packages/client/src/Socket.ts:53

Full WebSocket URL. When omitted it's derived from the page location (browser) as ws(s)://<host>:<port><path>. Required in non-browser environments.


path?

optional path?: string

Defined in: packages/client/src/Socket.ts:55

WebSocket upgrade path. Defaults to /app/ws (matches the broadcasting config default).


host?

optional host?: string

Defined in: packages/client/src/Socket.ts:57

Host override (defaults to location.hostname).


port?

optional port?: string | number

Defined in: packages/client/src/Socket.ts:59

Port override (defaults to location.port).


scheme?

optional scheme?: "ws" | "wss"

Defined in: packages/client/src/Socket.ts:61

Force a scheme. Defaults to wss on https pages, ws otherwise.


auth?

optional auth?: object

Defined in: packages/client/src/Socket.ts:68

Authentication for the connection and for private/presence channels:

  • params — query params appended to the WS URL (browsers can't set WS headers), read by the server on upgrade.
  • headers — sent on the POST /broadcasting/auth request (e.g. a CSRF token).

params?

optional params?: Record<string, string>

headers?

optional headers?: Record<string, string>


authEndpoint?

optional authEndpoint?: string | false

Defined in: packages/client/src/Socket.ts:74

Endpoint that signs a private/presence subscription (Pusher-style). Defaults to /broadcasting/auth. Set to false to skip the signature fetch and rely on connection-level authorization instead.


fetch?

optional fetch?: typeof fetch

Defined in: packages/client/src/Socket.ts:76

Inject a fetch implementation for the auth request (tests / non-DOM runtimes).


autoConnect?

optional autoConnect?: boolean

Defined in: packages/client/src/Socket.ts:78

Connect immediately on construction. Default: true.


reconnect?

optional reconnect?: boolean

Defined in: packages/client/src/Socket.ts:80

Reconnect automatically after an unexpected close. Default: true.


reconnectDelay?

optional reconnectDelay?: number

Defined in: packages/client/src/Socket.ts:82

Initial reconnect delay in ms (doubles each attempt up to maxReconnectDelay). Default: 1000.


maxReconnectDelay?

optional maxReconnectDelay?: number

Defined in: packages/client/src/Socket.ts:84

Cap on the reconnect backoff in ms. Default: 30000.


pingInterval?

optional pingInterval?: number

Defined in: packages/client/src/Socket.ts:86

Heartbeat ping interval in ms (0 disables). Default: 30000.


WebSocket?

optional WebSocket?: (url) => SocketLike

Defined in: packages/client/src/Socket.ts:88

Inject a WebSocket constructor (tests / non-DOM runtimes). Defaults to the global.

Parameters

url

string

Returns

SocketLike