Tiny (<4kb gzipped) WebSocket wrapper that automatically reconnects and buffers messages sent while disconnected. Version 0.2.1 is the latest stable release (no update cadence documented). Fully implements the standard WebSocket API (including readyState, EventTarget, and bufferedAmount) so it can be a drop-in replacement. The last release was in 2019 and the package appears to be in maintenance mode. Differentiates from alternatives like reconnecting-websocket by providing a complete WebSocket-compatible interface with configurable reconnection strategies (backoff, timeouts, max attempts).
npm install sturdy-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a sturdy WebSocket with exponential backoff reconnection and event handlers for open, message, down, and reopen.
Use 'down' and 'reopen' events for temporary disconnection notifications.
Run 'npm install ws' alongside sturdy-websocket.
Send periodic messages and await responses to detect dead connections.
Ensure options are passed as the third argument (after url and protocol) or as the second if no protocol.
Check readyState === OPEN before sending, or use maxReconnectAttempts to limit retries.
npm install ws
Change to 'import SturdyWebSocket from 'sturdy-websocket'' (no curly braces).
Use 'const SturdyWebSocket = require('sturdy-websocket').default'.Always pass a valid WebSocket URL as the first argument.