Skip to main content

Novu

The Novu client provides methods to interact with notifications, preferences, and real-time events.

Constructor Options

Usage

Notifications

Methods

list

Fetches a list of notifications based on provided filters.
The response will be of type:

count

Fetches the count of notifications based on filters.

read

Marks a notification as read.

unread

Marks a notification as unread.

seen

Marks a notification as seen.
Seen vs Read: Notifications can be “seen” (automatically tracked when visible) or “read” (explicitly marked by user interaction). The Inbox component automatically marks notifications as seen when they’re visible for 1+ seconds using the browser’s IntersectionObserver API. This automatic tracking batches requests for performance and works seamlessly with infinite scroll and pagination, while read status requires explicit user action.Why no unseen method? Unlike read/unread which can be toggled, seen is designed as a one-way operation. Once a notification has been seen by a user, it remains seen. This reflects the natural user experience where visibility cannot be “undone”. Use filtering with seen: false to get unseen notifications instead.

seenAll

Marks notifications as seen. You can filter them by notification IDs, tags, or data attributes.

archive

Archives a notification.

unarchive

Unarchives a notification.

readAll

Marks all notifications as read. You can filter them by tags.

archiveAll

Archives all notifications. You can filter them by tags.

archiveAllRead

Archives all read notifications. You can filter them by tags.

delete

Deletes a single notification permanently.

deleteAll

Deletes multiple notifications permanently. You can filter them by tags or data attributes.

snooze

Snoozes a notification for a specified duration. Here snoozeUntil is ISO 8601 formatted string timestamp, representing the date and time the notification is un-snoozed, it should be a future date and time.

unsnooze

Unsnoozes a notification.

completePrimary

Marks primary action of a notification as completed.

completeSecondary

Marks secondary action of a notification as completed.

revertPrimary

Reverts primary action of a notification to pending.

revertSecondary

Reverts secondary action of a notification to pending.

Notification

Individual notification instances have their own methods for marking as seen, read, archived, etc. These methods are available directly on each notification object.

Methods

  • seen() - Marks the notification as seen
  • read() - Marks the notification as read
  • unread() - Marks the notification as unread
  • archive() - Archives the notification
  • unarchive() - Unarchives the notification
  • delete() - Deletes the notification
  • snooze() - Snoozes the notification
  • unsnooze() - Unsnoozes the notification
  • completePrimary() - Marks primary action as completed
  • completeSecondary() - Marks secondary action as completed
  • revertPrimary() - Reverts primary action to pending
  • revertSecondary() - Reverts secondary action to pending
The seen() method is only available on individual notification instances, not on the novu.notifications object. Use novu.notifications.seenAll() for bulk operations.

Usage

Preferences

Methods

list

Fetches the subscriber’s notification preferences.

update

update method is available with each preference object.
The response will be of type:

bulkUpdate

Updates multiple workflow’s channel preferences at once.

Schedule

The preferences.schedule submodule lets you fetch and update a subscriber’s delivery schedule.

get

Fetches the subscriber’s schedule.

update

Updates the subscriber’s schedule. You can update the entire weekly schedule or only specific days.

Schedule Class

A Schedule instance is returned when fetching or updating a schedule.

Events

The Novu client provides real-time event handling through WebSocket connections.

Available Events

  • notifications.notification_received: Triggered when a new notification is received.
  • notifications.unread_count_changed: Triggered when the unread count changes.
  • notifications.unseen_count_changed: Triggered when the unseen count changes.
  • preferences.schedule.get.pending: Triggered when fetching a schedule starts.
  • preferences.schedule.get.resolved: Triggered when fetching a schedule succeeds.
  • preferences.schedule.update.pending: Triggered when updating a schedule starts.
  • preferences.schedule.update.resolved: Triggered when updating a schedule succeeds.
  • subscriptions.list.pending: Triggered when loading subscriptions starts.
  • subscriptions.list.resolved: Triggered when subscriptions are loaded.
  • subscriptions.get.pending: Triggered when fetching a subscription starts.
  • subscriptions.get.resolved: Triggered when a specific subscription is fetched.
  • subscriptions.create.pending: Triggered when creating a subscription starts.
  • subscriptions.create.resolved: Triggered when a subscription is created.
  • subscriptions.update.pending: Triggered when updating a subscription starts.
  • subscriptions.update.resolved: Triggered when a subscription is updated.
  • subscriptions.delete.pending: Triggered when deleting a subscription start.
  • subscriptions.delete.resolved: Triggered when a subscription is deleted.

Usage

Subscriptions

The Subscriptions module lets you manage a subscriber’s subscriptions to topics. A subscription represents a subscriber’s opt-in to a topic and defines which workflows within that topic they receive notifications from. It supports creating conditional subscriptions where users only receive notifications when the trigger payload matches a JSON Logic rule (for example, payload.tier is premium). Subscriber profile, Context data, and step results are not available in subscription conditions. Use step conditions for those cases. Manage subscriptions at two levels:
  • Module-level methods on novu.subscriptions
  • Instance-level methods on a TopicSubscription object

Methods

List

Fetches all subscriptions for a specific topic.
The response items are TopicSubscription instances.

get

Fetch a single subscription by topic and identifier.

create

Create a new subscription to a topic. You can pass a list of preferences to filter specific workflows or tags.

update

Updates an existing subscription.

delete

Delete a subscription by topic and subscription ID.

TopicSubscription

A TopicSubscription instance represents a single subscription and provides methods for updating or deleting it, as well as managing its preferences.

Update a subscription

Update subscription metadata or replace its preferences list. Use this method when updating the subscription as a whole. For granular preference updates, use preference-level methods instead.

Update SubscriptionPreference

Each subscription contains a list of SubscriptionPreference objects that you can update individually.

Delete a subscription (instance method)

Types

Notification

Subscriber