useNotifications hook provides a way to fetch and manage notifications in your application. It includes support for pagination, filtering, and real-time updates.
Hook Parameters
Return Value
Notification Type
The Notification type from @novu/react includes many properties. Here are the most commonly used ones:Example Usage
Here’s how to use theuseNotifications hook to fetch and display notifications:
With Filtering
You can filter notifications by various properties:read- Filter notifications by read statusseen- Filter notifications by seen statustags- Filter notifications by tags. If multiple tags are provided, Novu evaluates them usingORlogic, meaning a notification is included if it contains at least one of the specified tags.data- Filter notifications by data attributes (key-value pairs).severity- Filter notifications by severitylimit- Fetch notifications per pagecreatedGte- Fetch notifications created after the given date (in milliseconds)createdLte- Fetch notifications created before the given date (in milliseconds)
With Infinite Scroll
You can implement infinite scroll using thefetchMore function: