Migration Guide
This guide outlines the key differences between the @novu/notification-center
package and the new @novu/react
package. Follow the steps below to migrate your application to the latest version.
The @novu/react
package introduces a more flexible and customizable way to display notifications in your application. This guide outlines the key differences between the @novu/notification-center
package and the new @novu/react
package. Follow the steps below to migrate your application to the latest Inbox version.
Why you should upgrade to @novu/react
- Customization: The
@novu/react
package provides more customization options for the appearance and behavior of the notification components. - Flexibility: The new package offers more flexibility in handling notifications and integrating with third-party libraries.
- Performance: It is optimized for performance and provides a smoother user experience.
- Bundle Size: The new package has a smaller bundle size and improved tree-shaking capabilities.
- Compatibility with the
@novu/framework
: The@novu/react
package is designed to work seamlessly with the@novu/framework
package for creating and managing notifications.
Breaking Changes
The @novu/react
package introduces several breaking changes compared to the @novu/notification-center
package. Here are the key differences:
Components
- The
PopoverNotificationCenter
component has been replaced with theInbox
component. - The
NotificationCenter
component has been replaced with theNotifications
component. - The
NotificationBell
component has been replaced with theBell
component.
Styling
- The
styles
props is replaced by an enchanced and easy to useappearance
prop to customize the appearance of the notification components. For more information onappearance
customization visit here.
Notification
- Removal of
seen
,lastSeenDate
,content
,templateIdentifier
,payload
,cta
properties from the Notification object. - We have introduced
archive
functionality to the Notification object.
Getting Started
To begin migrating to @novu/react
, install the package via npm:
Basic Usage
- Old Implementation
- New Implementation with
@novu/react
Notification Center without Bell Icon
The @novu/react package introduces a flexible way to display notifications as a list without the default bell icon. Utilize the Inbox
and Notifications
components to achieve this functionality.
- Old Implementation
- New Implementation with
@novu/react
Custom Bell Icon
Customize the bell icon that triggers the notifications popover using the renderBell
prop.
- Old Implementation
- New Implementation with
@novu/react
Notification Actions
Handle user interactions with notifications effectively using the action handlers provided by @novu/react
.
onNotificationClick
Trigger a callback function when a user clicks on a notification item.
- Old Implementation
- New Implementation with
@novu/react
onPrimaryActionClick and onSecondaryActionClick
Handle primary and secondary actions within a notification explicitly.
- Old Implementation
- New Implementation with
@novu/react
Avatar Icons
Customize the avatar displayed alongside notifications by specifying an avatar URL
at the workflow definition level using @novu/framework
.
Popover Positioning
For advanced positioning and styling of the notifications popover, integrate third-party popover libraries such as Radix UI.
- Old Implementation
- New Implementation with
@novu/react
and Radix UI as an example
Custom Notification Item
Customize the appearance and structure of individual notification items using the renderNotification
prop.
- Old Implementation
- New Implementation with
@novu/react
Styling with appearance Prop
Customize the overall look and feel of the notification components using the appearance prop, which supports both CSS objects and class names (including Tailwind CSS classes).
- Old Implementation
- New Implementation with
@novu/react
For more information on appearance
customization visit here.
Multiple Tabs Support
Organize notifications into different categories using tabs by leveraging the tags property in workflow definitions and the tabs prop in the Inbox component.
Create Multiple Tabs
- Old Implementation
After defining the feeds on the Workflow UI, you were able to filter notifications based on the feedIdentifier.
- New Implementation with
@novu/react
- Define multiple workflows with relevant tags.
- Assign relevant tags to each workflow to categorize notifications appropriately.
Localization
Customize the language and text content of the notification components using the localization prop.
HMAC Encryption
The process remains the same as before. See the detailed guide here.
Handling Notifications
Handle notifications using the methods provided by the notification object.
Marking Notifications as Read
Mark notifications as read using the read
method provided by the notification object.
Marking Notifications as Unread
Mark notifications as unread using the unread
method provided by the notification object.
Marking Notifications as Archive
Mark notifications as archive using the archive
method provided by the notification object.
Marking Notifications as Unarchive
Mark notifications as unarchive using the unarchive
method provided by the notification object.
Was this page helpful?