Skip to Content

Resend

A send adapter template for delivering sign-in verification emails with Resend .

Installation

npm install resend

Plugin

Save this template as oberon/send.ts. Add its plugin export to your server configuration.

oberon/send.ts
import "server-cli-only" import { Resend } from "resend" import { USE_DEVELOPMENT_SEND_PLUGIN, type OberonPlugin } from "@oberoncms/core" const EMAIL_FROM = process.env.EMAIL_FROM const RESEND_SECRET = process.env.RESEND_SECRET || process.env.SEND_SECRET export const plugin: OberonPlugin = () => ({ name: "Resend", disabled: USE_DEVELOPMENT_SEND_PLUGIN, adapter: { sendVerificationRequest: () => async ({ email, token, url }) => { if (!RESEND_SECRET) throw new Error("No RESEND_SECRET configured") if (!EMAIL_FROM) throw new Error("No EMAIL_FROM configured") const resend = new Resend(RESEND_SECRET) const { error } = await resend.emails.send({ from: EMAIL_FROM, to: email, subject: "One time login to Oberon CMS", text: `Sign in with code\n\n${token}\n\n ${url} \n\n`, }) if (error) throw new Error(error.message) }, }, })

Environment variables

EMAIL_FROM=noreply@example.com RESEND_SECRET=your-resend-api-key

The template accepts SEND_SECRET if RESEND_SECRET is unset. Verify your sender domain with Resend before you send production email.

Last updated on