Skip to main content

Recipes

Broadcast to all connected clients

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

getWebSocketEngine().broadcast(JSON.stringify({ type: 'price.updated', payload: { symbol: 'ACME', price: 42 } }));

Send to a single connection

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

getWebSocketEngine().send(connectionId, JSON.stringify({ type: 'direct-message', payload: 'Hi there' }));

Change the upgrade path

Set websocket.path (WEBSOCKET_PATH) on @quik/websocket@quik/websocket-express reads the same key, so no adapter-specific configuration is needed.

Checklist

  • Enable both startHttpServer and startWebSocketServer bootstrap flags — the adapter needs an active HTTP server to attach the upgrade handler to.
  • Load @quik/websocket and @quik/http-express before @quik/websocket-express in the module list.