442 B
442 B
NestJ TypeScript WebSocket client
The connector uses the plain WebSocket protocol, not Socket.IO.
import { createWebSocketClient } from "./index.js";
const socket = createWebSocketClient("ws://localhost:8080/chat");
socket.onMessage(console.log);
await socket.connect();
socket.send("hello");
Browser builds use the platform WebSocket. Node.js projects can import
createNodeWebSocketClient from node.ts, which uses ws.