Initialise feed client
Using SuprSend client instance create Feed client instance.tenantId defaults to the active tenant set in identify or changeTenant, else the default tenant. Passing it here overrides the active tenant for that feed instance. Already running feed instances keep the tenant they were initialized with when changeTenant is called — re-initialize the feed to reflect the new tenant.
If you are passing tenant_id in feed, make sure to pass scope key while creating userToken else error will be thrown due to scope mismatching.
reachability defaults to false. Set it to true to track whether the feed is working for this user. See Tracking reachability.
Feed client
Get feed data
This returns notification store which contains list of notifications and other meta data like page information etc. You can call this anytime to get updated store data.Initialise socket for realtime update
Fetching notification data
This method will get first page of notifications from SuprSend server and set data in notification store.Fetch more notifications
This method will get next page of notifications from SuprSend server and set data in notification store.Listening for updates to store
Whenever there is update in notification store (ex: on new notification or existing notification state updated) this event is fired by library. You can listen to this event and update your local state so that UI of you application is refreshed.Listening for new notification
In case you want to show toast notification on receiving new notification you can use this listener.Tracking reachability
Reachability tells you whether the feed is working for this user right now. It combines three checks into one status: the browser is online, the feed socket is live, and the feed API is reachable. Use it to tell users when new notifications may be missing. It’s off by default. Turn it on when you create the feed client:norun
feed.reachability_change event:
norun
feedClient.reachability. It’s undefined when you didn’t pass reachability: true.
The event fires only when the overall status, socket.status, api.status or api.authError changes. It doesn’t fire on every request or reconnect attempt.
lastChangedAt updates only when the event fires. Each value is a frozen object, so read from it but don’t modify it.
ReachabilityStatus and ChannelStatus are exported from @suprsend/web-sdk. Each channel (socket and api) is UNKNOWN, CONNECTING, UP or DOWN. A channel stays UNKNOWN until it’s used, and an UNKNOWN channel is ignored.
The SDK picks the first status in this table that matches:
How each connection is tracked
- Browser: read from
navigator.onLineand the windowonlineandofflineevents. With nowindow(for example, during server-side rendering), the browser counts as online. - Socket:
CONNECTINGwhen you callinitializeSocketConnection(). It turnsUPonly after the server confirms the feed joined its room. If that confirmation doesn’t arrive within 5 seconds, it turnsDOWN. It also turnsDOWNafter more than 10 reconnect attempts. Disconnects caused byfeedClient.remove()are ignored. - API: measured on the first page fetch only. It’s
CONNECTINGwhenfetch()starts for an identified user,DOWNon a network error, andUPotherwise. A401or403on this initial load setsapi.authErrortotrueand the status toAUTH_ERROR. Later page fetches don’t change it.
Example: replicate the Inbox connection status
The ReactInbox component renders a coloured dot on the bell and a banner in the panel for each status. Here’s how to render the same states in a custom UI with the JavaScript SDK.
- Online
- Connecting
- Connection issue
- Authentication error
- Offline

norun
Removing feed
This will remove feed client data and abort socket connection. Additionally callingsuprSendClient.reset method during logout will also remove all feedClient instances attached SuprSend client instance.
Other methods
Example
For understanding purpose we have added current simple example in react. You could refer this headless example and design the feed in your Angular or Vue.js etc. If you want to implement in react please refer@suprsend/react-core or @suprsend/react





