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

import Fastify from "fastify";
import { Resent } from "resent.one";
const app = Fastify();
const resent = new Resent(process.env.RESENT_API_KEY);
app.post("/send", async () => {
return resent.emails.send({
from: "Acme <noreply@yourdomain.com>",
to: "you@example.com",
subject: "Hello from Fastify",
html: "<strong>It works!</strong>",
});
});
await app.listen({ port: 3000 });

Next steps