Skip to content

Documentation / @super-line/client / ClientOptions

Interface: ClientOptions<C, R>

Defined in: packages/client/src/index.ts:94

Options for createClient.

Type Parameters

C

C extends Contract

R

R extends RoleOf<C>

Properties

onValidationError?

optional onValidationError?: (error, info) => void

Defined in: packages/client/src/index.ts:108

Called when an inbound payload fails validation (only with validate: 'inbound').

Parameters

error

unknown

info

ValidationErrorInfo

Returns

void


params?

optional params?: Record<string, string>

Defined in: packages/client/src/index.ts:100

Extra query params appended to the URL (read in authenticate); role is added automatically.


reconnect?

optional reconnect?: boolean

Defined in: packages/client/src/index.ts:110

Auto-reconnect on drop. Defaults to true.


reconnectBaseMs?

optional reconnectBaseMs?: number

Defined in: packages/client/src/index.ts:112

Initial reconnect backoff in ms. Defaults to 500.


reconnectFactor?

optional reconnectFactor?: number

Defined in: packages/client/src/index.ts:116

Backoff growth factor. Defaults to 2.


reconnectMaxMs?

optional reconnectMaxMs?: number

Defined in: packages/client/src/index.ts:114

Maximum reconnect backoff in ms. Defaults to 30000.


role

role: R

Defined in: packages/client/src/index.ts:98

This client's role; narrows the surface and is sent to the server to verify.


serializer?

optional serializer?: Serializer

Defined in: packages/client/src/index.ts:102

Wire serializer; MUST match the server. Defaults to jsonSerializer.


timeoutMs?

optional timeoutMs?: number

Defined in: packages/client/src/index.ts:104

Default request timeout in ms. Defaults to 30000.


url

url: string

Defined in: packages/client/src/index.ts:96

The server URL, e.g. ws://localhost:3000.


validate?

optional validate?: "off" | "inbound"

Defined in: packages/client/src/index.ts:106

'inbound' re-validates server→client payloads against the contract (catches drift). Default 'off'.


WebSocket?

optional WebSocket?: {(url, protocols?): WebSocket; CLOSED: 3; CLOSING: 2; CONNECTING: 0; OPEN: 1; prototype: WebSocket; }

Defined in: packages/client/src/index.ts:118

Override the WebSocket implementation (defaults to globalThis.WebSocket).

Parameters

url

string | URL

protocols?

string | string[]

Returns

WebSocket

CLOSED

readonly CLOSED: 3

CLOSING

readonly CLOSING: 2

CONNECTING

readonly CONNECTING: 0

OPEN

readonly OPEN: 1

prototype

prototype: WebSocket

Released under the MIT License.