Sockette is a tiny (367 bytes) WebSocket wrapper with automatic reconnection, written by lukeed. Current stable version is 2.0.6. It provides a simple API to manage WebSocket connections, including automatic reconnection with configurable timeout and max attempts. Unlike raw WebSocket or heavier libraries like Socket.IO, Sockette is minimal and does not include fallback transports or extra features. It is ESM-only since v2 and includes TypeScript definitions. The package has low release cadence (last release 2020) and is considered stable and feature-complete.
npm install socketteNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a Sockette instance with event listeners, send a message and JSON, then close after 5 seconds.
Use import syntax or dynamic import if using CommonJS.
Set maxAttempts to a high value like 9999 instead of -1.
Use event.target inside event handlers to get the raw WebSocket instance.
Use 'import Sockette from "sockette"' or configure bundler to handle ESM.
Run 'npm install sockette' or 'yarn add sockette'.
No dependency data recorded yet.