Skip to main content

Introduction

Learn how to send notifications with Svelte, Svelte email and Novu. You can check out the complete code for a working app.

Prerequisites

  • A Novu account
  • Node installed on your machine
  • A working SvelteKit app

Follow these Steps

1. Install all dependencies

2. Integrate Novu with SvelteKit

Within the src/routes directory, create an api/novu folder and add a +server.ts file to it.

3. Create an email template in Svelte

Within the src/lib directory, create an emails folder and add an email template in a .svelte file to it. For example, airbnb-review.svelte:

4. Create a Novu Workflow

Next, create a Novu workflow with an email step. This code-first notification workflow approach makes it easy for product teams to modify notification content.

5. Preview Email Workflow & Sync to Novu Cloud

Open Dev Studio to preview and make changes to the email workflow as needed via the command below:
  1. Run the Studio

Novu Dev Studio on the first run

Note: Use the port on which your Svelte app is running for the Bridge endpoint so that the Novu Dev Studio can connect to your API route.
  1. Check out the email workflow and test

Preview Email workflow with Step Inputs & Payload

  1. Deploy to Novu Cloud when you’re done.
On the top right of the Novu Dev Studio, you can sync to Novu Cloud when you’re done working locally. Note: You’ll need to create a local tunnel that the Novu Cloud environment can reach for local experimentation purposes. Ngrok is a good tunnel.

6. Send a Notification

Trigger a notification using the recently deployed workflow either via your Novu Cloud dashboard or code. Once you’ve built the workflow, you might want read one of our other guides on how to empower product teams to manage notification workflows.