Skip to main content

Novu

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

Constructor Options

PropertyTypeDescription
backendUrlstring
applicationIdentifierstring
subscriberHashstring
contextHashstring
apiUrlstring
socketUrlstring
socketOptionsNovuSocketOptionsCustom socket configuration options. These options will be merged with the default socket configuration. Use socketType to explicitly select the socket implementation: 'cloud' for PartySocket or 'self-hosted' for socket.io. For socket.io-client connections, supports all socket.io-client options (e.g., path, reconnectionDelay, timeout, etc.). For PartySocket connections, options are applied to the WebSocket instance.
useCacheboolean
defaultScheduleDefaultSchedule
contextPartial<Record<string, ContextValue>>
subscriberIdstring
subscriberstring | Subscriber

Usage

Notifications

Methods

list

Fetches a list of notifications based on provided filters.
PropertyTypeDescription
tagsTagsFilter
readboolean
archivedboolean
snoozedboolean
seenboolean
dataRecord<string, unknown>
severitySeverityLevelEnum | SeverityLevelEnum[]
createdGtenumber
createdLtenumber
The response will be of type:
PropertyTypeDescription
notificationsNotification[]
hasMoreboolean
filterNotificationFilter

count

Fetches the count of notifications based on filters.
PropertyTypeDescription
tagsTagsFilter
readboolean
archivedboolean
snoozedboolean
seenboolean
dataRecord<string, unknown>
severitySeverityLevelEnum | SeverityLevelEnum[]
createdGtenumber
createdLtenumber

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:
PropertyTypeDescription
levelPreferenceLevel
enabledboolean
conditionRulesLogic
subscriptionIdstring
channelsChannelPreference
overridesIPreferenceOverride[]
workflowWorkflow
schedule{ isEnabled: boolean; weeklySchedule?: WeeklySchedule; }

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.
PropertyTypeDescription
isEnabledboolean
weeklyScheduleWeeklySchedule
update(args: UpdateScheduleArgs) => Result<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.
PropertyTypeDescription
topicKeystring
The response items are TopicSubscription instances.

get

Fetch a single subscription by topic and identifier.
PropertyTypeDescription
topicKeystring
identifierstring
workflowIdsstring[]
tagsstring[]

create

Create a new subscription to a topic. You can pass a list of preferences to filter specific workflows or tags.
PropertyTypeDescription
topicKeystring
topicNamestring
identifierstring
namestring
preferencesPreferenceFilter[]

update

Updates an existing subscription.
PropertyTypeDescription
namestring
preferencesPreferenceFilter[]

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.
PropertyTypeDescription
idstring
identifierstring
topicKeystring
preferencesSubscriptionPreference[]
update{ (args: BaseUpdateSubscriptionArgs): Result<TopicSubscription>; (args: InstanceUpdateSubscriptionArgs): Result<TopicSubscription>; }
updatePreference{ (args: BaseSubscriptionPreferenceArgs): Result<SubscriptionPreference>; (args: InstanceSubscriptionPreferenceArgs): Result<SubscriptionPreference>; }
bulkUpdatePreferences{ (args: Array<BaseSubscriptionPreferenceArgs>): Result<SubscriptionPreference[]>; (args: Array<InstanceSubscriptionPreferenceArgs>): Result<SubscriptionPreference[]>; }
delete() => Result<void>

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.
PropertyTypeDescription
subscriptionIdstring
workflowWorkflow
enabledboolean
conditionRulesLogic
update(args: { value: boolean | RulesLogic; }) => Result<SubscriptionPreference>

Delete a subscription (instance method)

Types

Notification

PropertyTypeDescription
idstring
transactionIdstring
subjectstring
bodystring
toSubscriber
isReadboolean
isSeenboolean
isArchivedboolean
isSnoozedboolean
snoozedUntilstring
deliveredAtstring[]
createdAtstring
readAtstring
firstSeenAtstring
archivedAtstring
avatarstring
primaryActionAction
secondaryActionAction
channelTypeChannelType
tagsstring[]
redirectRedirect
dataNotificationData
workflowWorkflow
severitySeverityLevelEnum
read() => Result<Notification>
unread() => Result<Notification>
seen() => Result<Notification>
archive() => Result<Notification>
unarchive() => Result<Notification>
delete() => Result<void>
snooze(snoozeUntil: string) => Result<Notification>
unsnooze() => Result<Notification>
completePrimary() => Result<Notification>
completeSecondary() => Result<Notification>
revertPrimary() => Result<Notification>
revertSecondary() => Result<Notification>
on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => () => void
off<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => void

Subscriber

PropertyTypeDescription
idstring
subscriberIdstring
firstNamestring
lastNamestring
emailstring
phonestring
avatarstring
localestring
dataRecord<string, unknown>
timezonestring