In-App UI
React
Hooks
useNotifications

useNotifications

The useNotifications hook is used to fetch and manage notifications for a user's feed. This hook provides notifications data along with loading states and pagination capabilities.

Parameters

#

Accepts an object (UseNotificationsParams) with the following properties:

feedIdstringRequired

The ID of the feed to fetch notifications for.

optionsFeedClientOptions

Optional configuration for the feed client.

Returns

#

A UseNotificationsReturn object with the following properties:

itemsKnockFeedItem[]

Array of notification items.

metadataFeedMetadata

Metadata about the feed including counts and pagination.

isLoadingboolean

Whether notifications are being loaded.

errorError | null

Error object if the request failed.

refresh() => void

Function to refresh the notifications feed.

Example

#

Basic usage

#

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