A Promise-based, low-level WebSocket server library for Node.js. Version 1.0.2 provides core functions for handling WebSocket handshakes, sending/receiving messages, and constructing frames per RFC 6455. Unlike high-level wrappers like 'ws', this library gives direct access to raw frames, opcodes, and masking, making it suitable for custom implementations such as rate limiters, custom close messages, or WebSocket extensions. It uses async iterables for message consumption and has a moderate release cadence. Key differentiators: full control over WebSocket protocol details, no abstraction layers, and TypeScript support.
npm install ws-low-levelNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a WebSocket server that echoes back text messages, demonstrating handshake, message sending/receiving, and frame construction.
Use import syntax or dynamic import() in CommonJS projects.
When sending frames to client, ensure the mask bit is set to 0. For server-to-client, mask should be 0; only client-to-server frames must be masked.
Only call sendHandshake after confirming the request is a valid WebSocket upgrade (check request headers).
Manually handle opcode 0x9 (Ping) to send a Pong frame using prepareWebsocketFrame with opcode 0xA.
Use import { sendHandshake } from 'ws-low-level' or use dynamic import: const ws = await import('ws-low-level')Ensure you access the socket from the 'upgrade' event, which is a net.Socket (or stream.Duplex).
Check that client sends 'Upgrade: websocket' and 'Connection: Upgrade' headers.
No dependency data recorded yet.