A lightweight wrapper for WebSocket that works in both Node.js and browser environments. Current stable version is 1.0.29. It provides a simple constructor-based API with callbacks for open, close, message, and error events. In Node.js it depends on the 'ws' package, but in the browser it uses native WebSocket with no dependencies. Key differentiator: unified API across platforms with automatic fallback, and UMD distribution for direct browser script tags. Low download count but functional for simple WebSocket use cases.
npm install w-websocket-clientNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a WebSocket client with an options object, connects to an echo server, sends a message, and logs received data.
Use correct import path: 'w-websocket-client/dist/w-websocket-client.umd.js'
Use window['w-websocket-client'] to access the constructor.
Set token to '*' unless the server requires authentication.
Use correct import: import WSC from 'w-websocket-client/dist/w-websocket-client.umd.js'
Use require('w-websocket-client/dist/w-websocket-client.umd.js')Use window['w-websocket-client'] to access the constructor.