Map of event names to argument tuples that clients can send to this server
Map of event names to argument tuples that this server can send to clients.
Defaults to IncomingEvents if not specified (bidirectional events).
Shape of the per-client mutable context bag accessible via client.context.
Defaults to Record<string, never> (no context) if not specified. When set, you must provide a
defaultContext option that will be structuredCloned into each new client.
Creates a new WebSocket server instance.
The server is not started until start is called.
Map of event names to argument tuples that clients can send to this server
Map of event names to argument tuples that this server can send to clients.
Defaults to IncomingEvents if not specified (bidirectional events).
Shape of the per-client mutable context bag accessible via client.context.
Defaults to Record<string, never> (no context) if not specified. When set, you must provide a
defaultContext option that will be structuredCloned into each new client.
Server and client behavior configuration. Must include one of: port (standalone),
server (external server), or noServer: true (manual upgrade handling).
Lifecycle callbacks for authentication, messages, disconnections, and errors.
Gets a shallow copy of the list of currently connected clients.
Sends a message to all currently connected and authenticated clients.
The event name to broadcast.
The arguments to send with the event.
Stops the server, closes all client connections, and clears the client list.
After calling this method, the server can no longer accept connections. The wss getter will return null.
Starts the server and begins listening for connections.
port), the promise resolves once the server is listening.A promise that resolves when the server is ready to accept connections.
WebSocket server with built-in authentication, type-safe events, and reply tracking.
Wraps the native
wsWebSocketServer and provides:Supports three operational modes:
portin options)serverin options)noServer: true)Example