Wse (WebSocket Everywhere!) is a lightweight WebSocket wrapper for Node.js (v14+) and browsers that adds authentication, RPC support, multi-device messaging, and custom protocol handling. Current stable version is 4.12.3, released periodically. It integrates seamlessly with Fastify, Express, or plain HTTP servers without requiring a dedicated WebSocket port. Key differentiators: built-in RPC-like API without brokers or routers, simple auth via the 'identify' callback, and channel-based broadcasting for multi-device scenarios.
npm install wseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a WseServer on port 4200 with simple auth, listens for 'chat' messages, registers a 'ping' RPC, and connects a WseClient to send messages and call RPC.
Always call accept('user-id') or reject(new Error('auth failed')) inside the identify callback.Set the 'channel' option on the server (or use the default channel) to enable broadcast.
Always use await client.connect() before sending or calling.
Pass an existing HTTP server to the WseServer constructor: new WseServer({ server: httpServer, identify: ... })Use import statements or set "type": "module" in package.json.
Replace const { WseServer } = require('wse') with import { WseServer } from 'wse'Ensure identify calls accept() or reject() correctly and the client URL is correct.
Set the 'channel' option on the server: new WseServer({ channel: 'myapp', ... })