Skip to main content

Function: subscribeToServerEvents()

subscribeToServerEvents(client, options?): ServerEventsSubscription

Subscribe to the API server's SSE events stream. Uses the ApiClient for authentication — JWT, session tokens, and API keys are all handled automatically via the client's axios interceptors. Returns an object with addEventListener(type, handler) for typed event handling and close().

Parameters​

client​

ApiClient

options?​

SubscribeToServerEventsOptions

Returns​

ServerEventsSubscription

Example​

const sub = subscribeToServerEvents(client);
sub.addEventListener('notification.new', (data) => { ... });
sub.addEventListener('asset.updated', (data) => { ... });
// on unmount: sub.close();