Lightweight, isomorphic WebSocket wrapper that adds named events, Promise-based request/response, channels, streaming, and cancellation on top of native WebSockets. Version 4.3.1 supports Node.js >=14, browsers, and Go. Unlike Socket.IO, it uses the native WebSocket protocol with no HTTP polling fallback, keeping the wire protocol simple and interoperable. Ships TypeScript types. Under 4 KB min+gzip.
npm install ws-wrapperNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a WebSocket server and client using SocketWrapper for request/response with named events.
Use wrapper.channel instead of wrapper.channel()
new SocketWrapper(ws) instead of new SocketWrapper(ws, options)
client.request('event', data, { signal })Wrap in ws.on('open', ...) or check readyStateUse wrapper.request(event, data).then(handler) instead of wrapper.request(event, data, callback)
Use import { SocketWrapper } from 'ws-wrapper'Use wrapper.channel instead of wrapper.channel()
Ensure WebSocket is open before using SocketWrapper, e.g., ws.on('open', () => { ... })No dependency data recorded yet.