If you’ve been in the Node.js ecosystem for a while, you know the ws library is the bedrock of real-time apps. But as we move further into a multi-runtime world—juggling Node, Bun, Deno, and Cloudflare Workers—the "old way" is starting to show its age.
I just came across @rabbx/ws, and it feels like the upgrade we've been waiting for. Here is why it’s making waves:
🚀 Zero Copy, Zero Deps: It’s a tiny 9KB (compared to 80KB+ for traditional setups). No native dependencies means no "node-gyp" headaches and lightning-fast installs.
🌍 True Cross-Platform: It runs the exact same code on Node, Bun, Deno, and the browser. It uses native hooks (like Bun.serve.websocket) where available to squeeze out maximum performance.
📈 Massive Scalability: Benchmarks show it handling 180k concurrent connections on Node with 2.6x less memory than the standard ws library.
One API, Every Runtime
The best part? It uses the Web Standard API (EventTarget, MessageEvent). No custom emitters to learn.
Here is how simple it is to spin up a server in Bun:
import { createBunServer } from '@rabbx/ws/server';
// 1. Setup the WebSocket logic
const { config, server: wss } = createBunServer({ path: '/ws' });
wss.addEventListener('connection', ({ detail: { socket } }) => {
socket.addEventListener('message', (e) => {
socket.send(`Echo: ${e.data}`);
});
});
// 2. Serve it
Bun.serve({
port: 3000,
fetch: config.fetch,
websocket: config.websocket
});
console.log("Server running on port 3000");
The Verdict
If you are looking to reduce your bundle size, lower your server costs, or finally write WebSocket code that actually runs on the Edge, give @rabbx/ws a look.
Check it out on GitHub: github.com/rabbxdev/ws
Top comments (0)