A tiny WebSocket client (~1KB bundled) with built-in reconnection and exponential backoff, offering callback/promise/stream-based message handling via emitterify. Version 1.1.0 is the current stable release. It is a lightweight alternative to heavier WebSocket libraries, focusing on minimal overhead and reconnection handling. The library works in browser and Node.js environments, but requires emitterify for stream/callback functionality.
npm install nanosocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a WebSocket connection, logs incoming messages, connection events, and sends a message.
Use socket.on('recv') instead of socket.on('message').Use socket.on('connected') and socket.on('disconnected') as provided by the library.Await the promise to ensure message is sent before proceeding.
Install @types/nanosocket or create a custom declaration file.
Ensure emitterify is installed: npm install emitterify. Check import path.
Ensure emitterify is loaded and socket is initialized properly.
Verify the WebSocket server URL and ensure it's accessible.