Skip to main content
useAppNotifications is the primary hook for building a notification feed. It loads notifications, tracks the unread count, handles pagination, and exposes actions for marking notifications as read.

Basic Usage

Parameters

number
Number of notifications to load per page: a whole number from 1 to 100. Defaults to 10. A larger value is rejected with 400 app-notification/invalid-query, never lowered to 100.
Partial<NotificationTemplates>
Optional map of display text templates for each notification type. See Notification Templates.

Returns

UnifiedAppNotification[]
The list of notification records. If notificationTemplates is provided, each notification is augmented with a title and/or content field derived from the template.
number
The total number of unread notifications for the current user.
boolean
true while a fetch is in progress.
SublayError | null
The last load failure, or null. Cleared when the next load starts; loadMore() retries it. Shared by every mounted useAppNotifications: there is one notifications list. A SublayError.
boolean
true while loadMore() has something to fetch: a next page, or a load that failed.
() => Promise<void>
Load the next page of notifications and append it, or retry the load that failed (a failed first page is retried as the first page). Does nothing while a page is loading or when there is nothing more. Never rejects: a failure lands in error.
({ notificationId: string }) => Promise<void>
Marks a single notification as read. Applies an optimistic update immediately before the API call.
() => Promise<void>
Marks all of the current user’s notifications as read. Applies an optimistic update immediately.
() => Promise<void>
Reload page 1. The loaded notifications stay until the new first page replaces them. Useful for pull-to-refresh. Never rejects: a failure lands in error.
The hook is backed by Redux. Notifications are shared globally in the Redux store — multiple instances of the hook in different components will share the same state.