Skip to main content

Overview

Redux-powered hook that provides a paginated notification feed for the current authenticated user. Loads notifications and unread count on mount, supports infinite scrolling via loadMore, and exposes mark-as-read actions with optimistic updates. For integration guidance and template configuration, see App Notifications.

Usage Example

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 display text templates for each notification type. Applied at render time. See Notification Templates.

Returns

UnifiedAppNotification[]
Array of notification records, augmented with title and content if templates are provided.
number
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 with an optimistic local update. If the request fails, the notification goes back to unread, the unread count is restored, and the promise rejects.
() => Promise<void>
Marks all notifications as read with an optimistic local update. If the request fails, the notifications that were unread go back to unread, the unread count is restored, and the promise rejects.
() => 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.
This hook requires the current user to be authenticated. It will not load until user and projectId are available.