A lightweight WebSocket library for Node.js at version 3.3.0 (released 2023). It provides a simple API to create WebSocket servers and clients, with session-based event handling (data, close). The library supports both Node.js and browser environments. Key differentiators: minimal dependencies, straightforward stream-like API, and no external WebSocket library required (uses native 'net' and 'crypto' modules). Release cadence is sporadic, with the last update in 2023.
npm install websocket-libNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a WebSocket server on port 8080, echos back messages with 'Hello ', and a client connects, sends 'Client', and logs the server response.
Use session callback in createServer() instead of server.on('connection', ...).Use ESM imports (import ... from 'websocket-lib') or use dynamic import() inside CJS.
Add session.setEncoding('utf8') in the connection callback to receive strings.Use the global WebSocket class in browsers; do not import websocket-lib client-side.
Switch to ESM: import { createServer } from 'websocket-lib'Use import() dynamic import or convert project to ESM.
Use createServer((session) => { session.send(...) })No dependency data recorded yet.