Quickstart
Load @quik/websocket, @quik/http-express, and @quik/websocket-express together and enable the WebSocket server flag:
import { Module as WebSocketModule } from '@quik/websocket';
import { Module as HttpExpressModule } from '@quik/http-express';
import { Module as WebSocketExpressModule } from '@quik/websocket-express';
import { setup } from '@quik/bootstrap';
await setup({
flags: {
startHttpServer: true,
startWebSocketServer: true
},
modules: [WebSocketModule, HttpExpressModule, WebSocketExpressModule]
});
Send data to connections from anywhere in the app via the active engine:
import { getWebSocketEngine } from '@quik/websocket';
const engine = getWebSocketEngine();
engine.send(connectionId, JSON.stringify({ type: 'notification', payload: 'Hello' }));
engine.broadcast(JSON.stringify({ type: 'announcement', payload: 'Server restarting' }));
Notes
- The adapter attaches WebSocket upgrade handling to the existing
@quik/http-expressHTTP server — no separate port is opened. - It listens on
websocket.path(default/ws) and usesQWebSocketHeartbeatServicefor browser-compatible ping/pong checks.