Express

Send email from Express route handlers.

Send email from Express route handlers.

Install

$npm i resent.one

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

Send an email

1import express from "express";
2import { Resent } from "resent.one";
3
4const app = express();
5const resent = new Resent(process.env.RESENT_API_KEY);
6
7app.post("/send", async (_req, res) => {
8 const result = await resent.emails.send({
9 from: "Acme <noreply@yourdomain.com>",
10 to: "you@example.com",
11 subject: "Hello from Express",
12 html: "<strong>It works!</strong>",
13 });
14 res.json(result);
15});
16
17app.listen(3000);

Next steps