useNotifications
function useNotifications(opts?): object;Loads the caller’s notification feed and keeps unseen/unread counts. markSeen/markRead
are optimistic: they zero (mark-all) or decrement (mark-ids) the local counter and stamp
the rows before the request resolves, rolling back on error — same discipline as
useReactions. Pass pollInterval to refresh counts on a timer.
Inert inside a disabled provider: empty list, zero counts, isLoading: false,
error: null, enabled: false; markSeen/markRead no-op resolve undefined.
markSeen(ids?) / markRead(ids?) reject after rolling back — see the file header.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
opts? |
{ live?: boolean; pollInterval?: number; } |
- |
opts.live? |
boolean |
Keep notifications fresh via the cheap head check. See useFeed’s live. |
opts.pollInterval? |
number |
:::caution[Deprecated] Use live: true — cheaper and visibility-aware. Ignored when live is set. ::: |
Returns
Section titled “Returns”object
enabled
Section titled “enabled”enabled: boolean;error: Error | null;hasNext
Section titled “hasNext”hasNext: boolean;isLoading
Section titled “isLoading”isLoading: boolean;loadNext
Section titled “loadNext”loadNext: () => Promise<void>;Returns
Section titled “Returns”Promise<void>
markRead
Section titled “markRead”markRead: (ids?, opts?) => Promise<void>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ids? |
string[] |
opts? |
{ onError?: OptimisticOnError; } |
opts.onError? |
OptimisticOnError |
Returns
Section titled “Returns”Promise<void>
markSeen
Section titled “markSeen”markSeen: (ids?, opts?) => Promise<void>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ids? |
string[] |
opts? |
{ onError?: OptimisticOnError; } |
opts.onError? |
OptimisticOnError |
Returns
Section titled “Returns”Promise<void>
notifications
Section titled “notifications”notifications: Notification[];refresh
Section titled “refresh”refresh: () => Promise<void>;Returns
Section titled “Returns”Promise<void>
unread
Section titled “unread”unread: number;unseen
Section titled “unseen”unseen: number;Throws
Section titled “Throws”The network error after the optimistic stamp has been rolled back. This is the
footgun that crashed the FC Urban notification bell in live testing (Aug 2026) when the
upstream notifications endpoint started 500’ing: an uncaught promise rejection in their
onClick handler bubbled to the React error boundary. Always wrap in
try { await markSeen() } catch {} (or .catch(() => {})) for fire-and-forget callers.