ws

A simple, blazing-fast, thoroughly tested WebSocket client and server library for Node.js.

Library
npm
v8.21.3
22,800stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
85/100Excellent
Development Activity76
Maintenance80
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture87
Code Quality88
Innovation84
Learning Curve85

ws is the de facto standard WebSocket implementation for Node.js, providing both client and server APIs that closely mirror the browser’s native WebSocket interface. It implements the full HyBi 07-17 WebSocket protocol drafts (RFC 6455), including the permessage-deflate compression extension, and is validated against the Autobahn test suite for both client and server conformance.

Because it has no required runtime dependencies and exposes low-level primitives like its own Sender and Receiver classes, ws is frequently used both directly by application developers building real-time features and as the underlying transport inside higher-level libraries (Socket.IO, engine.io, and many others) across the Node.js ecosystem.

What You Get

  • A WebSocket client class with an API modeled closely on the browser’s native WebSocket, including send, close, event handlers, and an EventTarget-compatible mode
  • A WebSocketServer class supporting standalone listening, attachment to existing HTTP/S servers, and manual noServer upgrade handling for routing multiple WebSocket endpoints
  • Built-in support for the permessage-deflate compression extension with fine-grained tuning options (window bits, memory level, context takeover)
  • Optional native addons (bufferutil, utf-8-validate) that are auto-detected and used to accelerate frame masking/unmasking and UTF-8 validation
  • A Node.js streams-compatible duplex wrapper (createWebSocketStream) for piping WebSocket data through the standard streams API
  • Broadcast-friendly server APIs (wss.clients) for iterating and messaging all connected clients

Common Use Cases

  • Building real-time chat, notification, or collaborative editing backends that push data to connected clients over a single persistent connection
  • Implementing low-latency game or trading-data servers where full-duplex, low-overhead messaging outperforms polling-based HTTP
  • Acting as the transport layer underneath higher-level realtime frameworks (Socket.IO, engine.io) or custom RPC-over-WebSocket protocols
  • Proxying or bridging WebSocket traffic in gateways and API servers that need to multiplex several WebSocket endpoints behind one HTTP server

Under The Hood

Architecture: ws separates concerns cleanly across lib/: websocket.js implements the client-facing WebSocket state machine (connecting, opening, handshake, close negotiation) as an EventEmitter; websocket-server.js implements WebSocketServer, handling HTTP upgrade requests, subprotocol/extension negotiation, and client bookkeeping; and the actual wire protocol is split into sender.js (frame construction, masking, optional deflate) and receiver.js (a Writable stream implemented as an explicit state machine — GET_INFO, GET_PAYLOAD_LENGTH_16/64, GET_MASK, GET_DATA, INFLATING, DEFER_EVENT — that incrementally parses HyBi frames off the incoming socket). permessage-deflate.js implements the negotiated compression extension on top of Node’s zlib, and stream.js adapts a WebSocket into a Node.js Duplex for standard streams interop. index.js composes all of these into the single exported WebSocket class with static properties attached (Server, Receiver, Sender, createWebSocketStream).

Tech Stack: Pure JavaScript targeting Node.js >=10, with zero required runtime dependencies — bufferutil and utf-8-validate are declared only as optional peer dependencies that are dynamically required if present, accelerating masking/unmasking and UTF-8 validation with native addons while falling back to pure-JS implementations otherwise. The package ships dual entry points (index.js for CommonJS require, wrapper.mjs for ESM import, browser.js as a browser-safe stub) declared via the exports map in package.json. Development tooling is ESLint 10 + Prettier for linting/formatting and Mocha + nyc for testing and coverage.

Code Quality: The test suite is extensive — 12 dedicated *.test.js files under test/ covering the receiver state machine, sender, permessage-deflate, extension negotiation, subprotocol parsing, buffer utilities, validation, the WebSocket stream wrapper, and both client and server behavior, plus a separate websocket.integration.js and Autobahn conformance runners (autobahn.js, autobahn-server.js) for full protocol-compliance testing. Source files are consistently documented with JSDoc comments on every exported class and method, private state uses a _-prefixed convention, and internal-only cross-module state uses Symbol keys (kWebSocket, kStatusCode, etc.) to avoid polluting public APIs — a deliberate, disciplined approach to encapsulation for a library operating this close to the wire.

API Design: The client API is intentionally shaped to match the browser’s native WebSocket (new WebSocket(url), .send(), .on('message', ...), readyState constants), which minimizes the learning curve for anyone who has used WebSockets in a browser and enables isomorphic wrapper packages. The 739-line doc/ws.md reference documents every constructor option, event, and method in detail, and the README leads with copy-pasteable examples for the most common scenarios (simple client, simple server, external HTTP server, multi-endpoint routing, authentication, broadcast, round-trip time, streams). Getting a minimal client or server running takes only a few lines of code with no required configuration.

Used by 109 apps in this directory

TypeScript
86%
MIT

Agents Observe

Developer Tools

667

A real-time, fully local observability dashboard for Claude Code and Codex agent sessions — filtering, search, session replay, and token/cost breakdowns via an auto-starting MCP server.

View details
65
Repo Health
67
Technical
77
Dependency
Built with
TypeScript86%
JavaScript10%
Updated 3 days ago
TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,622

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
87
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated 5 days ago
PHP
82%
Other

Akaunting

Invoicing Finance

10,111

Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.

View details
98
Repo Health
73
Technical
63
Dependency
Built with
PHP82%
Blade13%
Updated yesterday
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

65,696

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
90
Repo Health
78
Technical
64
Dependency
Built with
JavaScript95%
Updated 3 days ago
TypeScript
49%
MPL 2.0

Artillery

Devops · Developer Tools

9,071

Cloud-scale load testing and functional testing for APIs, WebSockets, gRPC, and headless browsers, distributed across AWS Lambda or Fargate with zero infrastructure to manage.

View details
88
Repo Health
73
Technical
68
Dependency
Built with
TypeScript49%
JavaScript48%
Updated 1 weeks ago
TypeScript
92%
GPL 3.0

Blinko

Knowledge Management · Note Taking

10,992

A self-hosted, AI-powered card note-taking tool that lets you capture fleeting thoughts instantly and retrieve them with natural language search.

View details
80
Repo Health
69
Technical
63
Dependency
Built with
TypeScript92%
Updated 1 weeks ago
TypeScript
79%
GPL 3.0

Bramble

Password Manager · Security · Authentication

381

Local-first, end-to-end encrypted password manager that syncs your vault directly between your own devices over a private peer-to-peer mesh — no server, no account, no cloud in the middle.

View details
75
Repo Health
84
Technical
72
Dependency
Built with
TypeScript79%
Updated 3 days ago
TypeScript
90%
Other

browserless

Developer Tools · Automation

13,666

Run headless Chrome, Firefox, and WebKit as a managed Docker service — drop-in Puppeteer and Playwright support with no infrastructure overhead.

View details
84
Repo Health
82
Technical
73
Dependency
Built with
TypeScript90%
Updated 2 days ago
Rust
67%
MIT

Bun

Developer Tools

95,895

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
64
Dependency
Built with
Rust67%
C++19%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search