Defjs
Core

UseWebSocketConfig

WebSocket fields of RequestOptions, plus signal.

@defjs/core · Type

Signature

type UseWebSocketConfig<
  TIncoming = unknown,
  TOutgoing = unknown,
> = UseWebSocketBaseConfig<TIncoming, TOutgoing> & {
  signal?: AbortSignal;
};

beforeConnect, heartbeat, protocols, and reconnect override the client-level options for one call. signal covers the whole session, including after it opens. There is no startup-only deadline and no abort field.

Members

Prop

Type

beforeConnect? ((context: { attempt: number; signal: AbortSignal; }) => void | Promise<void>) | undefined
heartbeat? WebSocketHeartbeatConfig<TIncoming, TOutgoing> | undefined
protocols? readonly string[] | undefined
reconnect? { attempts?: number; delayMs?: number; factor?: number; jitter?: number; maxDelayMs?: number; shouldReconnect?: (context: { attempt: number; cause?: unknown; code?: number; reason?: string; wasClean?: boolean; }) => boolean; } | undefined
signal? AbortSignal | undefined

Aborts the session, including after it is open.

Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao