Skip to content

lspeasy / core/src / createWebSocketClient

Function: createWebSocketClient()

ts
function createWebSocketClient(url): WebSocketLike;

Defined in: packages/core/src/transport/websocket.ts:136

Creates a WebSocket client instance, preferring the native globalThis.WebSocket (Node ≥ 22.4 / modern browsers) and falling back to the optional ws peer dependency.

Parameters

ParameterTypeDescription
urlstringThe WebSocket server URL to connect to.

Returns

WebSocketLike

A WebSocketLike instance that is currently connecting.

Remarks

This is a low-level factory used internally by WebSocketTransport in client mode. You rarely need to call it directly.

Throws

If neither globalThis.WebSocket nor the ws package is available.

Released under the MIT License.