Vercel Functions

Send email from Vercel Serverless and Edge Functions.

Send email from Vercel Serverless and Edge Functions.

Install

$npm i resent.one

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

Send an email

1// api/send.ts
2import type { VercelRequest, VercelResponse } from "@vercel/node";
3import { Resent } from "resent.one";
4
5export default async function handler(_req: VercelRequest, res: VercelResponse) {
6 const resent = new Resent(process.env.RESENT_API_KEY);
7 const result = await resent.emails.send({
8 from: "Acme <noreply@yourdomain.com>",
9 to: "you@example.com",
10 subject: "Hello from Vercel",
11 html: "<strong>It works!</strong>",
12 });
13 return res.status(200).json(result);
14}

Next steps