Send Email from Next.js
Deploy email infrastructure and send your first email from a Next.js application in under 5 minutes.
Deploy email infrastructure and send your first email from a Next.js application in under 5 minutes.
Before you begin, make sure you have:
Run the Wraps CLI to deploy email infrastructure to your AWS account:
npx @wraps.dev/cli email initWhat happens during deployment?
Add and verify your sending domain with AWS SES:
npx @wraps.dev/cli email domains add -d yourdomain.comDNS Setup
The CLI will output DKIM records to add to your DNS provider. Once added, verify them with npx @wraps.dev/cli email domains verify -d yourdomain.com
Install the @wraps.dev/email package in your Next.js project:
npm install @wraps.dev/emailCreate a server action to send emails directly from your Next.js components:
'use server'import { WrapsEmail } from '@wraps.dev/email';const email = new WrapsEmail();export async function sendWelcomeEmail(to: string, name: string) { const result = await email.send({ from: 'hello@yourdomain.com', to, subject: `Welcome, ${name}!`, html: `<h1>Welcome to our app, ${name}!</h1><p>We're glad you're here.</p>`, }); return { messageId: result.messageId };}Alternatively, create an API route for sending emails from any client:
import { NextResponse } from 'next/server';import { WrapsEmail } from '@wraps.dev/email';const email = new WrapsEmail();export async function POST(request: Request) { const { to, subject, html } = await request.json(); const result = await email.send({ from: 'hello@yourdomain.com', to, subject, html, }); return NextResponse.json({ messageId: result.messageId });}Deploy your Next.js application to Vercel. Wraps uses OIDC for secure authentication with no AWS access keys needed.
Vercel OIDC Authentication
When deploying to Vercel, Wraps uses OIDC for authentication — no AWS access keys needed. Just set AWS_ROLE_ARN in your Vercel environment variables.
Learn about all available methods, options, and advanced features.
View SDK DocsBuild reusable email templates with TypeScript and React.
View GuideReference for all error codes and troubleshooting steps.
View Errors