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.
@novu/react Inbox react component and @novu/js headless package is compatible with @novu/framework based workflows only. With old UI based workflows, our old @novu/notification-center component should be used.
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/reactpackage 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/reactpackage is designed to work seamlessly with the@novu/frameworkpackage 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
PopoverNotificationCentercomponent has been replaced with theInboxcomponent. - The
NotificationCentercomponent has been replaced with theNotificationscomponent. - The
NotificationBellcomponent has been replaced with theBellcomponent.
Styling
- The
stylesprops is replaced by an enchanced and easy to useappearanceprop to customize the appearance of the notification components. For more information onappearancecustomization visit here.
Notification
- Removal of
seen,lastSeenDate,content,templateIdentifier,payload,ctaproperties from the Notification object. - We have introduced
archivefunctionality 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/reactand 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.