A lightweight (<600 bytes gzipped) drop-in replacement for the native WebSocket API that automatically reconnects when the connection drops. Version 0.1.0 is a fork of the original reconnecting-websocket library, updated to track the latest master branch. It is API-compatible with WebSocket, so you can replace 'new WebSocket(url)' with 'new ReconnectingWebSocket(url)' and get automatic reconnection with exponential backoff (configurable via options like reconnectInterval, maxReconnectInterval, reconnectDecay). It supports all standard WebSocket events (onopen, onmessage, onclose, onerror) and methods (send, close). Compared to alternatives, it is minimal and has no dependencies, but note that this fork may not see active maintenance.
npm install shopify-reconnecting-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: import, instantiate with options, and event listeners for open, message, close, and error events.
Use import ReconnectingWebSocket from 'shopify-reconnecting-websocket' or const { default: ReconnectingWebSocket } = require('shopify-reconnecting-websocket')Use only one style: either addEventListener or onopen, not both simultaneously.
Switch to the original reconnecting-websocket or use robust-ws.
Set binaryType in the options object or immediately after instantiation and before opening.
Use const { default: ReconnectingWebSocket } = require('shopify-reconnecting-websocket')Ensure correct import: import ReconnectingWebSocket from 'shopify-reconnecting-websocket'
Install and import a WebSocket implementation like 'ws' and assign to global: global.WebSocket = require('ws')No dependency data recorded yet.