browser-websocket is a small wrapper around the native WebSocket API designed to simplify websocket usage in browser and Node.js environments. Version 2.2.0 is the latest stable release, but the package appears dormant with no recent updates. It provides an EventEmitter-like interface (on/emit) for handling WebSocket events, making it similar to socket.io but without the complex protocols. The package aims to offer a drop-in solution for browser websocket communication with a simple API. However, it lacks TypeScript types and has known event-handling pitfalls.
npm install browser-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a websocket connection to ws://localhost:8000, emit a message on open, log incoming messages and close event.
Use ws.emit(data) to send messages; there is no send method.
Access e.data for the message content.
Migrate to the standard WebSocket API (new WebSocket(url)) or use a maintained library.
Use require('browser-websocket') instead of import; if using TypeScript, add // @ts-ignore or use a dynamic import.Replace ws.send(data) with ws.emit(data).
No dependency data recorded yet.