WebSocket Heartbeat for MiniProgram
JSON →Websocket-heartbeat-miniprogram (v1.0.3) is a lightweight WebSocket heartbeat library designed for WeChat Mini Programs and compatible platforms (Alipay, Baidu, Uni-app, Taro). It wraps the mini-program's WebSocket API with automatic heartbeat detection and reconnection logic, ensuring stable long-lived connections in unreliable network environments. Key differentiator: it handles platform-specific quirks (e.g., Alipay's single-socket limit) and preserves custom event hooks across reconnections, unlike the native socketTask that loses listeners after reconnect. The library is ESM-only, returns a promise, and provides a task object with stable hooks (onOpen, onClose, onMessage, onError, onReconnect) as well as the raw socketTask. Release cadence appears low; last release was a while ago. The package has minimal dependencies and is focused solely on mini-program environments.