@tahanabavi/typesocket
Contract-driven Socket.IO for TypeScript. Declare each event once with its direction and Zod schemas, and the client generates itself — every frame validated on the way out and on the way in, acknowledgements included.
Overview
Realtime that can't drift from its contract.
typesocket is the WebSocket side of TypeWire. You declare each Socket.IO event once — with the direction it travels and its Zod schemas — and the client is generated from that contract. There is no event name to mistype and no payload shape to keep in sync.
Every frame is validated on the way out and on the way in, acknowledgements included. It shares typefetch's "module.event" identifier scheme and its instrument() seam, so HTTP and WebSocket traffic land in one devtools timeline with no adapter glue.
- One contract, both ends — the same object drives the client and a server gateway, each reading the direction tag from its own point of view.
- Validated frames — a bad payload throws (or rejects) instead of going out, and an invalid inbound frame never reaches your handler.
- Stable ids — every event carries an eventId like "chat.sendMessage", the same shape typefetch uses, so caches and devtools key both transports alike.