Skip to content

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.

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. :::

object

enabled: boolean;
error: Error | null;
hasNext: boolean;
isLoading: boolean;
loadNext: () => Promise<void>;

Promise<void>

markRead: (ids?, opts?) => Promise<void>;
Parameter Type
ids? string[]
opts? { onError?: OptimisticOnError; }
opts.onError? OptimisticOnError

Promise<void>

markSeen: (ids?, opts?) => Promise<void>;
Parameter Type
ids? string[]
opts? { onError?: OptimisticOnError; }
opts.onError? OptimisticOnError

Promise<void>

notifications: Notification[];
refresh: () => Promise<void>;

Promise<void>

unread: number;
unseen: number;

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.