Quickstart

Novu Vue Quickstart Guide

Create an account and learn how to start using Novu Inbox in your vue application.

This guide walks you through integrating Novu's Inbox into your Vue application for real time in-app notifications, from setup to triggering your first notification. By the end, you'll have a working notification inbox.

This guide uses @novu/js javascript sdk to build the Inbox component in Vue. Novu currently does not support native Vue Inbox component.

Create a Vue application

Create a new vue app with create-vue package. Skip this step if you already have an existing project:

npm create vue@latest novu-inbox-vue

Navigate to the newly created project:

cd novu-inbox-vue
npm install

Install the required package

Run the command below to install Novu Javascript SDK, which provides required component for Inbox UI:

npm install @novu/js

Add the Inbox component

Create the src/components/NovuInbox.vue file to add the Inbox component passing and :

src/components/NovuInbox.vue
<template>
  <!-- 
    This empty div serves as a mounting point for the Novu Inbox.
    We use Vue's ref attribute to get direct access to this DOM element.
  -->
  <div ref="novuInbox"></div>
</template>
 
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from "vue";
import { NovuUI } from "@novu/js/ui";
 
interface NovuOptions {
  options: {
    applicationIdentifier: string;
    subscriberId: string;
  };
}
 
// Create a reactive reference to hold the DOM element
const novuInbox = ref<HTMLElement | null>(null);
// Store the Novu instance for cleanup during unmount
let novuInstance: NovuUI | null = null;
 
onMounted(() => {
  // Ensure our div reference exists before proceeding
  if (!novuInbox.value) {
    console.error("Novu inbox container element not found");
    return;
  }
 
  try {
    // Initialize the Novu UI instance with required configuration
    const novu = new NovuUI({
      options: {
        applicationIdentifier: 'YOUR_APPLICATION_IDENTIFIER',
        subscriberId: 'YOUR_SUBSCRIBER_ID',
      },
    } as NovuOptions);
 
    // Mount the Inbox component to our div reference
    // This is where Novu creates and injects its Inbox UI
    novu.mountComponent({
      name: "Inbox",
      props: {},
      element: novuInbox.value, // The actual DOM element where Inbox will be mounted
    });
 
    // Store the instance for cleanup
    novuInstance = novu;
  } catch (error) {
    console.error("Failed to initialize Novu inbox:", error);
  }
});
 
// Clean up when the component is destroyed
onUnmounted(() => {
  if (novuInstance && novuInbox.value) {
    try {
      // Properly unmount the Novu component to prevent memory leaks
      novuInstance.unmountComponent(novuInbox.value);
    } catch (error) {
      console.error("Failed to unmount Novu inbox:", error);
    }
  }
});
</script>

Sign in to get your own API keys

If you're signed in to your Novu account, then the and are automatically entered in the code sample above. Otherwise, you can manually retrieve them:

  • applicationIdentifier - In the Novu dashboard, click API Keys, and then locate your unique Application Identifier.
  • subscriberId - This represents a user in your system (typically the user's ID in your database). For quick start purposes, an auto-generated subscriberId is provided for your Dashboard user.

Note: If you pass a subscriberId that does not exist yet, Novu will automatically create a new subscriber with that ID.

Add the Inbox component to your application

Import and use the NovuInbox component in src/App.vue file:

src/App.vue
<script setup lang="ts">
import NovuInbox from "./components/NovuInbox.vue";
</script>
 
<template>
  <NovuInbox />
</template>

Run Your Application

Start your development server:

npm run start

Once the application is running, a bell icon will appear on the top left side of the screen. Clicking it opens the notification inbox UI.

Currently, there are no notifications. Let's trigger one!

Trigger your first notification

In this step, you'll create a simple workflow to send your first notification via the Inbox component. Follow these steps to set up and trigger a workflow from your Novu dashboard.

  1. Go to your Novu dashboard.
  2. In the sidebar, click Workflows.
  3. Click Create Workflow. Enter a name for your workflow (e.g., "Welcome Notification").
  4. Click Create Workflow to save it.
  5. Click the Add Step icon in the workflow editor and then select In-App as the step type.
  6. In the In-App template editor, enter the following:
  • Subject: "Welcome to Novu"
  • Body: "Hello, world! "
  1. Once you've added the subject and body, close the editor.
  2. Click Trigger.
  3. Click Test Workflow.

View the notification in your app

Go back to your Vue app, then click the bell icon.

You should see the notification you just sent from Novu! 🎉

Next steps

On this page