Koa

Send email from Koa middleware and routes.

Send email from Koa middleware and routes.

Install

npm i resent.one

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

Send an email

import Koa from "koa";
import Router from "@koa/router";
import { Resent } from "resent.one";
const app = new Koa();
const router = new Router();
const resent = new Resent(process.env.RESENT_API_KEY);
router.post("/send", async (ctx) => {
ctx.body = await resent.emails.send({
from: "Acme <noreply@yourdomain.com>",
to: "you@example.com",
subject: "Hello from Koa",
html: "<strong>It works!</strong>",
});
});
app.use(router.routes());
app.listen(3000);

Next steps