Fastify

Send email from Fastify routes.

Send email from Fastify routes.

Install

$npm i resent.one

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

Send an email

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

Next steps