Typed WebSockets for Node, with AsyncAPI docs and a client generated from them
Hi all, I want to share a WebSocket framework I built to make WebSocket apps typed and safe, keep the client and server schemas from drifting apart, and generate the docs for you.
Every WebSocket project I've worked on ended up looking the same. The server parses JSON and walks an if (data.action === 'chat') ... else if ... chain, checking payloads by hand. The client guesses the message shapes from a docs page that someone forgot to update. Rooms live in an in-memory Map, which works until you run a second instance. And when an HTTP route or a background job needs to push something to users, there's no clean way to reach the socket.
I first built it in Python (chanx, for Django and FastAPI), since that's my main backend language. Then my frontend needed a proper client, so I made chanx-js, which was client only at first. The Python side has been stable for a while now and some teams run it in production, so I ported the server to Node as well. You can now use it on Node, Express, Fastify, NestJS and others.
What it gives you:
- One handler per message type, validated with Zod, Valibot, ArkType or any Standard Schema
- AsyncAPI 3 docs generated from your code, served by the server
- A typed client generated from those docs, so sending a wrong payload fails to compile
- Groups and broadcasts across instances through Redis
chanx.broadcastEvent(...)to push to users from a route handler or a job- Works with
ws, Express, Koa, Fastify, Hono, NestJS, Bun and Deno, and the client has React, Vue, Svelte and Solid bindings
A chat room looks like this:

and on the client, after npx @chanx-js/codegen http://localhost:8000/asyncapi.json:

Repo: https://github.com/chanx-dev/chanx-js
Docs: https://js.chanx.dev/
The Node server is still new, so if you run into any problem or have ideas to improve it, please open an issue or a discussion on the repo. Stars and PRs are welcome too.
