Create Custom Inbox UI with React Hooks
Learn how to build a custom notifications UI using React hooks powered by Novu
The @novu/react
package offers an interface that enables you to build a custom notifications UI using React hooks that are powered by real-time data from the Novu services.
These hooks are designed for use in both mobile and web applications, offering a flexible approach to building a custom notifications UI tailored to your application's requirements.
Getting Started
Follow these steps to get started with building your custom inbox UI:
To implement the NovuProvider component, you need to place it in your application's code at the tree level where you want the hooks to be accessible.
You can find the applicationIdentifier
in the Novu Dashboard under the API keys page.
The subscriberId
is the unique identifier of the user in your application, learn more about subscribers here.
For example, you can create a custom popover UI with a bell icon that shows the unread notifications count and a list of notifications.
Bell Button with Unread Count
The BellButton
component fetches the unread notifications count and renders the count value in the indicator:
Notifications List
The NotificationsList
component retrieves and displays the notifications list with infinite scrolling functionality:
Notification Item
The NotificationItem
component renders each notification item. When any action is performed on the notification
instance (e.g., "read" button is clicked), the SDK will optimistically update the notification, which will trigger a rerender of the useNotifications
hook.
Learn more about the Hook interfaces in the React SDK documentation.