Headless notification Inbox for JavaScript applications

Learn how to use the Novu Inbox API to build your own inbox

The headless version of Novu’s notification library package provides users with a lightweight solution for integrating notification functionality into their web applications. With just the essential API methods, users can easily incorporate our notification system into any framework or vanilla JavaScript project, without being constrained by our default UI or dependencies. The SDK includes real-time notifications through a WebSocket connection and can be safely used across web browsers.

Install the SDK

npm i @novu/js

Initialize the SDK

import { Novu } from "@novu/js";
 
const novu = new Novu({
  apiKey: 'YOUR_API_KEY',
});

Fetch notifications

const response = await novu.notifications.list({
  limit: 30,
});
 
const notifications = response.data.notifications;

Display notifications in your UI.

Realtime Notifications

Events are emitted when notifications are received, and when the unread notificatons count changes. novu.on() is used to listen to these events.

novu.on("notifications.notification_received", (data) => {
  console.log("new notification =>", data);
});
 
novu.on("notifications.unread_count_changed", (data) => {
  console.log("new unread notifications count =>", data);
});

For the full list of methods available, see the API Reference.

On this page