Docs
/
In-App UI
React
Hooks
useNotifications

useNotifications

The useNotifications hook initializes and manages a feed client instance for a user's notification feed. This hook handles the lifecycle of the feed client, including initialization, real-time updates, and cleanup.

Parameters

#
knockKnockRequired

An authenticated Knock client instance.

feedChannelIdstringRequired

The UUID of the in-app feed channel from your Knock dashboard.

optionsFeedClientOptions

Optional configuration for the feed client (e.g., archived, status, page_size).

Returns

#

Returns a Feed client instance. The Feed client provides methods for fetching items, marking items as read/seen/archived, and subscribing to real-time updates. See the Feed client reference for the full API.

Example

#

Basic usage

#

The following example demonstrates how to use the useNotifications hook with useNotificationStore to display notifications.

Using with KnockProvider and KnockFeedProvider

#

When using the provider pattern, you can access the feed client through context: