Skip to main content
Version: v10.0.0

TrpcWebsocketAdapterOptionsType

Options of the tRPC WebSocket connection, passed as adapterOptions to the Socket . They can be changed per connection attempt with socket.onConnect , e.g. to send a fresh auth token.


Import
import { TrpcWebsocketAdapterOptionsType } from "@hyper-fetch/trpc"

Preview​

type TrpcWebsocketAdapterOptionsType = {
WebSocket?: typeof WebSocket;
autoConnect?: boolean;
connectionParams?: TrpcConnectionParamsType;
keepAlive?: TrpcKeepAliveOptionsType;
protocols?: string | string[];
}

Structure​

TrpcWebsocketAdapterOptionsType
NameTypeDescription
WebSocket
typeof WebSocket

The WebSocket class to use, for example from the ws package. Defaults to the global one (browsers, Node.js 22+, Bun, Deno).

autoConnect
boolean

Connect when the socket is created. Only the first connection depends on it - a socket connected by hand also reconnects after a lost connection and when the app goes back online.

connectionParams
TrpcConnectionParamsType

Sent as the first message of every connection, before any subscription starts. The server reads them in createContext as info.connectionParams .

keepAlive
TrpcKeepAliveOptionsType

Sends PING on a quiet connection and reconnects when the server does not answer

protocols
string | string[]

Subprotocols passed to the WebSocket constructor ( Sec-WebSocket-Protocol header)