sendsend.email

Send email with Next.js

A server-side call to the SendSend API from your Next.js app.

  1. Create a test API key in the dashboard first: it never delivers real email. Switch to a live key once your domain is verified.
  2. Add SENDSEND_API_KEY to .env.local (and to your host’s environment variables for production).
  3. Add this to app/api/send/route.ts:
export async function POST(req: Request) {
  const { to } = await req.json();
  const res = await fetch('https://api.sendsend.email/v1/emails', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.SENDSEND_API_KEY}`,
      'Content-Type': 'application/json',
      'Idempotency-Key': crypto.randomUUID(),
    },
    body: JSON.stringify({ from: 'Acme <hello@mail.acme.com>', to: [to], subject: 'Hello from Next.js', html: '<p>It works!</p>' }),
  });
  return Response.json(await res.json(), { status: res.status });
}

Call this from a server action or an API route. Never put the key in a client component.

Good to know