@novu/react/Hooks
useCounts
Learn how to use the useCounts hook to fetch notification counts in your React application
The useCounts
hook provides a way to fetch various notification counts, including unread, unseen, total counts, or filtered by severity. This hook is useful for displaying notification badges and indicators in your application.
Hook parameters
Prop | Type | Default |
---|---|---|
onError? | (error: NovuError) => void | - |
onSuccess? | (data: Count[]) => void | - |
filters | NotificationFilter[] | - |
Return value
Example usage
Here's how to use the useCounts
hook to fetch and display various notification counts, including unread, unseen, and counts based on severity.
The counts are automatically updated in real-time when notifications are marked as read/unread or when new notifications arrive.