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 foroptionsFeedClientOptions
Optional configuration for the feed clientReturns#
A UseNotificationsReturn
object with the following properties:
itemsKnockFeedItem[]
Array of notification itemsmetadataFeedMetadata
Metadata about the feed including counts and paginationisLoadingboolean
Whether notifications are being loadederrorError | null
Error object if the request failedrefresh() => void
Function to refresh the notifications feedExample#
Basic usage#
The following example demonstrates how to use the useNotifications
hook to display notifications.