Create Custom Inbox UI with React Hooks
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:
Install the @novu/react package
Implement the NovuProvider
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. Here’s how you can do it:
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.
Create the custom Inbox UI
For example, you can create a custom popover UI with a bell icon that shows the unread notifications count and a list of notifications.
The BellButton
component fetches the unread notifications count and renders the count value in the indicator.
The NotificationsList
component retrieves and displays the notifications list with infinite scrolling functionality.
The NotificationItem
component renders each notification item.
When any action is performed on the notification
instance for example “read” button is clicked,
the SDK will optimistically update notification that will result in the useNotifications
hook rerender, so yo don’t need to refetch and manually update your UI.
Was this page helpful?