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

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

Next steps