The email API built for
Next.js developers
Send transactional emails from Server Actions, API routes, or middleware. TypeScript-first with full type safety.
Get started in seconds
Install the package and start sending emails.
npm install getmailerCode examples
Drop-in examples for the most common Next.js patterns.
Server Action
Send emails directly from a Server Action. No API route needed.
"use server"
import { getmailer } from "@/lib/getmailer"
export async function sendWelcomeEmail(email: string, name: string) {
await getmailer.emails.send({
from: "[email protected]",
to: email,
subject: `Welcome, ${name}!`,
template: "welcome",
variables: { name },
})
}API Route
Use a standard App Router API route for webhook-driven emails or third-party integrations.
import { NextResponse } from "next/server"
import { getmailer } from "@/lib/getmailer"
export async function POST(request: Request) {
const { to, subject, html } = await request.json()
const result = await getmailer.emails.send({
from: "[email protected]",
to,
subject,
html,
})
return NextResponse.json({ id: result.id })
}NextAuth password resets
Wire up GetMailer as the email provider for NextAuth magic links and password resets.
import NextAuth from "next-auth"
import { getmailer } from "@/lib/getmailer"
export const { handlers, auth } = NextAuth({
providers: [
{
id: "email",
type: "email",
sendVerificationRequest: async ({ identifier, url }) => {
await getmailer.emails.send({
from: "[email protected]",
to: identifier,
subject: "Sign in to YourApp",
template: "magic-link",
variables: { url },
})
},
},
],
})Built for the Next.js ecosystem
First-class support for everything in the Next.js toolchain.
TypeScript types included
Full type definitions out of the box. Autocomplete for every method and option.
Works with App Router & Pages Router
Use with the latest App Router or the classic Pages Router. Both fully supported.
Edge Runtime compatible
Runs on Edge Runtime for the fastest cold starts. Deploy to Vercel Edge Functions.
Server Actions support
Call getmailer directly from Server Actions. No API route needed.
Middleware-friendly
Use in Next.js middleware for auth flows, rate limiting emails, and more.
Vercel & Railway ready
Zero config deployment. Environment variables are all you need.
Ready to get started?
Start sending emails from Next.js in under 5 minutes.