Documentation / zerotal / client / SocketOptions
Interface: SocketOptions
Defined in: packages/client/src/Socket.ts:48
Properties
url?
optionalurl?: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?
optionalpath?:string
Defined in: packages/client/src/Socket.ts:55
WebSocket upgrade path. Defaults to /app/ws (matches the broadcasting config default).
host?
optionalhost?:string
Defined in: packages/client/src/Socket.ts:57
Host override (defaults to location.hostname).
port?
optionalport?:string|number
Defined in: packages/client/src/Socket.ts:59
Port override (defaults to location.port).
scheme?
optionalscheme?:"ws"|"wss"
Defined in: packages/client/src/Socket.ts:61
Force a scheme. Defaults to wss on https pages, ws otherwise.
auth?
optionalauth?: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 thePOST /broadcasting/authrequest (e.g. a CSRF token).
params?
optionalparams?:Record<string,string>
headers?
optionalheaders?:Record<string,string>
authEndpoint?
optionalauthEndpoint?: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?
optionalfetch?: typeoffetch
Defined in: packages/client/src/Socket.ts:76
Inject a fetch implementation for the auth request (tests / non-DOM runtimes).
autoConnect?
optionalautoConnect?:boolean
Defined in: packages/client/src/Socket.ts:78
Connect immediately on construction. Default: true.
reconnect?
optionalreconnect?:boolean
Defined in: packages/client/src/Socket.ts:80
Reconnect automatically after an unexpected close. Default: true.
reconnectDelay?
optionalreconnectDelay?:number
Defined in: packages/client/src/Socket.ts:82
Initial reconnect delay in ms (doubles each attempt up to maxReconnectDelay). Default: 1000.
maxReconnectDelay?
optionalmaxReconnectDelay?:number
Defined in: packages/client/src/Socket.ts:84
Cap on the reconnect backoff in ms. Default: 30000.
pingInterval?
optionalpingInterval?:number
Defined in: packages/client/src/Socket.ts:86
Heartbeat ping interval in ms (0 disables). Default: 30000.
WebSocket?
optionalWebSocket?: (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