Skip to main content

Send Email with Next.js

This guide shows you how to send transactional emails using Sequenzy in a Next.js application.

Prerequisites

1. Install

Install the Sequenzy SDK and React Email:

2. Configure Environment

Add your API key to .env.local:
.env.local

3. Create an Email Template

Create a React Email component:
components/emails/welcome-email.tsx

4. Create an API Route

App Router

Create an API route at app/api/send/route.ts:
app/api/send/route.ts

Pages Router

Create an API route at pages/api/send.ts:
pages/api/send.ts

5. Send the Email

Call your API route from anywhere in your application:

Using Templates

Instead of rendering HTML with React Email, you can use pre-built templates from the Sequenzy dashboard:
This approach lets non-developers update email templates without code changes.

Server Actions (App Router)

You can also send emails using Server Actions:
app/actions/send-email.ts
Then use it in your component:

Next Steps

React Email Components

Explore all available React Email components

Transactional Emails

Learn more about transactional emails