| .. | ||
| .gitignore | ||
| browser.ts | ||
| bun.lock | ||
| index.ts | ||
| node.ts | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| ws.d.ts | ||
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.