To use this example, you'll need an account on Knock, as well as an in-app feed channel, with a workflow that produces in-app feed messages. You'll also need:
- A public API key for the Knock environment (set as
- The channel ID for the in-app feed (set as
Authenticating the current user
Initialize a feed connection for the user
Knock class exposes a
Feed via the
initialize method that can be used to connect the authenticated user to a Knock Feed Channel. Additionally, the
Feed exposes a stateful store to build client-side feeds and other notification experiences.
Marking feed item statuses
A feed instance supports marking items as seen, unseen, read, unread, archived, and unarchived:
Retrieving preferences for the user
You can use the JS SDK to retrieve the preferences for the authenticated user, which is useful to build in-app preference UIs.
Setting preferences for the user
Similar to retrieving preferences, the
Knock class also allows you to set preferences directly in the client for the authenticated user.