Wraps Logo
Quickstart / Next.js

Send Email from Next.js

Deploy email infrastructure and send your first email from a Next.js application in under 5 minutes.

Prerequisites

Before you begin, make sure you have:

  • Node.js 18 or later installed
  • AWS credentials configured (AWS Setup Guide)
  • A domain you own

1
Deploy Infrastructure

Run the Wraps CLI to deploy email infrastructure to your AWS account:

GNU Bashterminal.sh
npx @wraps.dev/cli email init

What happens during deployment?

  • Validates your AWS credentials
  • Prompts you to choose a configuration preset (Starter, Production, or Enterprise)
  • Shows estimated monthly AWS costs
  • Deploys SES, DynamoDB, Lambda, EventBridge, and IAM roles to your AWS account
  • Takes 1-2 minutes to complete

2
Add Your Domain

Add and verify your sending domain with AWS SES:

GNU Bashterminal.sh
npx @wraps.dev/cli email domains add -d yourdomain.com

DNS 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

3
Install the SDK

Install the @wraps.dev/email package in your Next.js project:

GNU Bashterminal.sh
npm install @wraps.dev/email

4
Send from a Server Action

Create a server action to send emails directly from your Next.js components:

TypeScriptapp/actions/send-email.ts
'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 };}

5
Send from an API Route

Alternatively, create an API route for sending emails from any client:

TypeScriptapp/api/send/route.ts
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 });}

6
Deploy to Vercel

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.

Next Steps

Email SDK Reference

Learn about all available methods, options, and advanced features.

View SDK Docs
Templates as Code

Build reusable email templates with TypeScript and React.

View Guide
Error Codes

Reference for all error codes and troubleshooting steps.

View Errors

Need Help?

If you run into any issues, check our GitHub discussions or open an issue.

Get Help