DEV Community

Cover image for The End of "Heavy" WebSockets: Introducing @rabbx/ws
rabbxdev
rabbxdev

Posted on

The End of "Heavy" WebSockets: Introducing @rabbx/ws

The Node.js ecosystem has relied on the ws library for 15 years. It’s reliable, but it was built for a different era—one before Bun, Deno, and Cloudflare Workers redefined the edge.
Enter @rabbx/ws: a zero-dependency, zero-copy WebSocket library designed for 2026. It’s smaller, faster, and truly universal.

Why Move Away from ws?

While the classic ws package is the industry standard, it carries baggage. It’s roughly 80KB with dependencies and relies heavily on Node-specific native hooks.
@rabbx/ws strips away the bloat:

  • Ultra-Lightweight: Only 9KB gzipped with zero dependencies.
  • Web Standard API: No more learning custom event emitters. It uses EventTarget, MessageEvent, and CloseEvent—the same API you use in the browser.
  • Performance First: It’s 3x faster on Bun (by leveraging native Bun.serve) and uses 2.6x less memory than traditional libraries. ### Performance Breakdown If you're running high-concurrency applications, the memory savings alone are a game changer.
Metric ws (Node 20) @rabbx/ws (Node 20)
Throughput 380k msg/s 450k msg/s
Max Connections 65k 180k
RAM (10k conns) 1.8GB 680MB

One Import, Every Runtime

The biggest headache in modern web dev is writing code that works on Node but breaks on a Cloudflare Worker. @rabbx/ws solves this by providing specialized helpers for every major runtime while keeping the socket API identical.

1. Bun (The Speed King)

import { createBunServer } from '@rabbx/ws/server';
const { config, server: wss } = createBunServer({ path: '/ws' });
Bun.serve({
  port: 3000,
  fetch: config.fetch,
  websocket: config.websocket
});
wss.addEventListener('connection', ({ detail: { socket } }) => {
  socket.send('Hello from Bun!');
});
Enter fullscreen mode Exit fullscreen mode

2. Node.js (The Reliable Standard)

import { createServer } from 'http';
import { createServer as createWSS } from '@rabbx/ws/server';
const httpServer = createServer().listen(3000);
const wss = createWSS(httpServer, { path: '/ws' });
wss.addEventListener('connection', ({ detail: { socket } }) => {
  socket.addEventListener('message', (e) => socket.send(e.data));
});
Enter fullscreen mode Exit fullscreen mode

Should You Switch?

Use @rabbx/ws if:

  • You are building cross-platform tools.
  • You are running on Bun or Edge functions (Deno/Workers).
  • You need to maximize connections per GB of RAM.
  • You prefer the standard Web API over proprietary emitters. Stick with ws if:
  • You require permessage-deflate (compression) immediately (support for this is coming to @rabbx/ws soon in RFC 7692). ### Get Started Ready to lighten your stack? Installation is a one-liner:
 Pick your poison
npm i @rabbx/ws
bun add @rabbx/ws
pnpm add @rabbx/ws
Enter fullscreen mode Exit fullscreen mode

Check out the GitHub Repository to see the full documentation and benchmarks.
https://github.com/rabbxdev/ws

Top comments (0)