A simple, blazing fast, and thoroughly tested WebSocket client and server implementation for Node.js.
ws is a WebSocket library for Node.js that provides both client and server implementations for real-time, bidirectional communication. It solves the need for efficient and reliable WebSocket connections in Node.js applications, enabling features like live chat, notifications, and data streaming. The library is designed to be simple, fast, and thoroughly tested against the Autobahn test suite.
Node.js developers building applications that require real-time communication, such as chat systems, live dashboards, gaming servers, or collaborative tools. It's also suitable for those needing a lightweight, spec-compliant WebSocket implementation without browser dependencies.
Developers choose ws for its exceptional performance, extensive testing, and minimal API that stays true to the WebSocket protocol. It offers optional performance optimizations, compression support, and seamless integration with Node.js ecosystems, making it a trusted choice for production real-time applications.
Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
Uses optional binary addons like bufferutil to optimize data masking and unmasking, making it one of the fastest WebSocket libraries for Node.js, as highlighted in the opt-in performance section.
Passes the comprehensive Autobahn test suite for both client and server, ensuring high reliability and adherence to modern WebSocket standards like HyBi drafts 07-17.
Supports permessage-deflate extension with tunable parameters for selective compression, reducing bandwidth while allowing control over performance and memory trade-offs, as detailed in the WebSocket compression section.
Can attach to existing HTTP/S servers and run multiple WebSocket servers on a single HTTP instance, simplifying deployment in complex setups without major refactoring.
Provides createWebSocketStream() to treat WebSocket connections as Node.js streams, enabling easy piping and data flow management for seamless integration with other stream-based modules.
Designed exclusively for Node.js; browser clients must use the native WebSocket object or third-party wrappers like isomorphic-ws, adding complexity for isomorphic or full-stack applications.
Enabling permessage-deflate can cause significant memory fragmentation and slow performance under high concurrency, as warned in the README due to Node.js's known zlib bugs.
Requires installing additional modules like bufferutil for optimal performance, which may lack prebuilt binaries for some platforms and complicates setup with potential environment variable overrides.
Focuses on low-level WebSocket protocol; lacks built-in utilities for common patterns like pub/sub or automatic reconnection, forcing developers to implement them manually.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.