// the find
lukeed/sockette
The cutest little WebSocket wrapper! 🧦
Sockette is a 367-byte wrapper around the native WebSocket API that adds automatic reconnection and a reusable instance model. It solves the annoying problem of having to re-attach all event listeners every time WebSocket reconnects. Aimed at anyone who needs a plain WebSocket connection without pulling in a full socket library.
The size is the story — 367 bytes gzipped means there is genuinely nothing here you don't need. Reusing the instance across reconnections is the right design; recreating the socket under the hood while keeping the same external reference avoids a class of bugs where listeners pile up. The close-code check (skipping reconnect on 1000/1001/1005) shows someone actually read the WebSocket spec rather than blindly reconnecting on every close. TypeScript definitions ship alongside the source, so you're not hunting for a @types package.
No backoff strategy — the reconnect interval is a fixed timeout, so a server restart will immediately get hammered by every connected client at once. Last meaningful commit was 2024 and the repo has basically been in maintenance mode for years; the 79 forks vs 2400+ stars ratio suggests people are patching it themselves rather than upstream. No support for binary message handling beyond passing through whatever WebSocket.send() accepts — if you're doing anything with ArrayBuffers you're on your own. The event model is options-only, meaning you can't add a second onmessage handler after construction without monkey-patching.