Skip to main content

useScopeUnread

The useScopeUnread hook returns a lightweight unread count for a specific notification query scope.

Parameters

params
NotificationListParams
Same filtering options used by useNotifications (scope, organization IDs, workspace IDs, and more).

Return Value

count
number
Unread count for the selected scope.
loading
boolean
Whether unread count is loading.
error
Error | null
Error from the latest request.
refetch
() => Promise<void>
Revalidate unread count.

Example

import { useScopeUnread } from "@wacht/react-router";

function WorkspaceUnread({ workspaceId }: { workspaceId: string }) {
  const { count, loading } = useScopeUnread({
    scope: "workspace",
    workspace_ids: [workspaceId],
  });

  if (loading) return <span>...</span>;
  return <span>{count}</span>;
}