Skip to content

useNotifications

useNotifications returns a live list from the client notification store. It re-renders the consumer when notifications are added, removed, or updated, and can optionally filter to an exact notification target.

Usage

import { useNotifications } from "stream-chat-react-native";

const notifications = useNotifications({
  filter: (n) => n.severity === "error",
});

By default (no target and no requireTarget: true), the hook returns every notification in the store. This is useful for global analytics or debug views. Pass an exact target to scope to a specific channel, thread, channel list, or thread list. This hook does not infer NotificationTargetProvider context on its own; use useNotificationTargetContext or useResolvedNotificationTarget when you need the surrounding target.

Options

Option Type Description
filter (notification: Notification) => boolean Predicate run after target filtering. Returns the notifications you want to read.
requireTarget boolean When true, return an empty array if no target is provided. Used by NotificationList to guarantee panel-scoped reads even when the call site has no context.
target { hostId: string; panel: NotificationTargetPanel } Restrict results to notifications tagged for this exact target. Use useResolvedNotificationTarget to derive one from context.

Returns

Notification[]: a stable reference that changes when the matching notifications change. See the Notification type in stream-chat for the full shape.

  • useClientNotifications is the unscoped counterpart: it reads every notification from the client store (client.notifications.store) and takes no options or target filtering. Use it for a simple global read when you don't need filter/target scoping. Returns { notifications }.
  • useSystemNotifications reads only notifications tagged system.
  • useNotificationListController wraps useNotifications with snackbar selection + timeout logic.