Send Email with Next.js
This guide shows you how to send transactional emails using Sequenzy in a Next.js application.Prerequisites
- A Sequenzy account with an API key
- A verified sending domain
- A Next.js application
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 atapp/api/send/route.ts:
app/api/send/route.ts
Pages Router
Create an API route atpages/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:Server Actions (App Router)
You can also send emails using Server Actions:app/actions/send-email.ts