Skip to main content

Quickstart

@quik/websocket defines the heartbeat protocol and adapter contract; pair it with a server adapter like @quik/websocket-express to actually accept connections.

Client-side, respond to heartbeat pings with the provided helper:

import { attachWebSocketHeartbeat } from '@quik/websocket';

const socket = new WebSocket('ws://localhost:7200/ws');
const detachHeartbeat = attachWebSocketHeartbeat(socket);

// later, when the socket is no longer used
detachHeartbeat();

Notes

  • The heartbeat uses ordinary JSON WebSocket messages (quik.websocket.ping/quik.websocket.pong), not native protocol ping frames, so browser clients can participate without special APIs.
  • getWebSocketEngine() returns the currently configured IQWebSocketEngine adapter instance.