Next.js

Send transactional email from App Router route handlers or Server Actions.

Send transactional email from App Router route handlers or Server Actions.

Install

$npm i resent.one

Set RESENT_API_KEY in your server environment. Keep the key off the client.

Send an email

1// app/api/send/route.ts
2import { Resent } from "resent.one";
3
4export async function POST() {
5 const resent = new Resent(process.env.RESENT_API_KEY);
6 const result = await resent.emails.send({
7 from: "Acme <noreply@yourdomain.com>",
8 to: "you@example.com",
9 subject: "Hello from Next.js",
10 html: "<strong>It works!</strong>",
11 });
12 return Response.json(result);
13}

Next steps