Realtime > Realtime Overview
Realtime > Realtime OverviewKroxt BaaS SDK v1.0.5

Realtime Overview

Connect your frontend to an event-driven WebSockets gateway to subscribe to database modifications, track online status rosters, and broadcast custom events instantly.

Prerequisites:
  • Active WebSocket network connection.
Initialize WebSockets Connection:
realtime.ts
1
2
3
4
5
6
7
8
// Connect manually to the WebSocket gateway (e.g. after login)
baas.realtime.connect();

// Reconnect automatically when the access token updates
baas.http.onTokenRefresh(async (newToken) => {
  console.log("Token rotated, reconnecting socket...");
  await baas.realtime.reconnect();
});