ReferenceAsk
A

Realtime

Subscribe to backend events in the browser: connect once, receive publishes live, and let the SDK handle reconnection and grant renewal.
import { createClient } from '@mindstudio-ai/interface';

The frontend half of realtime. events.connect opens a managed subscription to the app's event stream and hands back a handle you close on unmount. You give it a getToken that calls one of your backend methods to mint a grant, and an onEvent for the payloads; the SDK holds the stream open, reconnects with backoff when the network drops, and re-mints the grant through getToken each time it expires. None of that is code you have to write.

Because events are at-most-once nudges, the correctness half of the contract lives in onConnect. It fires on every connect and reconnect, and it is where you refetch current state, since anything that happened while the client was away was never buffered. Subscribe for speed, reconcile for truth. A getToken that throws is terminal rather than retried, because a refusal from your own method means the user is logged out or no longer permitted; the SDK calls onError and closes, and you reconnect when your app's auth state changes.

3 entries
Methods 1
Types 2