A JavaScript WebSocket utility library that provides heartbeat, auto-reconnection, and message retransmission for browser environments. Current stable version is 1.0.6. It was extracted from the tools-vue3 library to be used standalone in plain HTML/JS or any JavaScript project. Key differentiators: built-in heartbeat mechanism to detect stale connections, automatic reconnection with customizable intervals, and reliable message retransmission ensuring messages are not lost during disconnection. It ships with TypeScript type definitions and is ESM-only.
npm install tools-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a WebSocket connection with heartbeat, auto-reconnect, and a message handler.
Use import syntax or configure your project to handle ESM (e.g., type: 'module' in package.json, or use dynamic import()).
Set heartbeatInterval: 0 to disable, or configure heartbeatMessage to send a custom message and listen for a response.
Implement idempotency keys on the server side or limit retransmission count.
Add "type": "module" to your package.json or rename file to .mjs, or use dynamic import().
Use a WebSocket polyfill like 'ws' and set global.WebSocket before importing tools-websocket.
No dependency data recorded yet.