Documentation

Email (Resend)

Transactional email with Resend — verification, password reset, templates, and adding new emails.

Open inChatGPT (opens in a new tab)Claude (opens in a new tab)Cursor (opens in a new tab)Transactional email with Resend — verification, password reset, templates, and adding new emails.

Motoko Base sends auth and account emails through Resend. This is transactional email only — not marketing.

Official docs: Resend documentation

Setup

  1. Create a Resend account
  2. Create an API key (send permission)
  3. Add and verify your sending domain (SPF/DKIM) — or use onboarding@resend.dev for local tests
  4. Set env vars:
VariablePurpose
RESEND_API_KEYServer-only API key
EMAIL_FROMSender, e.g. My App <noreply@yourdomain.com>

Also keep BETTER_AUTH_URL aligned with your public URL — Better Auth builds verification/reset links from it.

Without Resend the app boots, but verification and password reset emails won't send.

What sends automatically

EmailTriggerTemplate
VerificationSign up / resendverification-email.tsx
Password resetForgot passwordpassword-reset-email.tsx
WelcomeAccount createdwelcome-email.tsx

Better Auth owns tokens and URLs (src/lib/auth/auth.ts). The email layer only delivers via src/lib/email/ helpers.

Templates

src/lib/email/templates/
  shared.tsx              # layout, brand name
  verification-email.tsx
  password-reset-email.tsx
  welcome-email.tsx

Built with @react-email/components. Edit copy and styling in the template files. Brand name: shared.tsx.

Add a new transactional email

  1. Create src/lib/email/templates/your-email.tsx (use TransactionalEmailLayout from shared.tsx)
  2. Export sendYourEmail(...) from src/lib/email/index.ts
  3. Call it from a server action, webhook, or auth hook — never from client components

Only src/lib/email/client.ts imports the Resend SDK directly.

Auth UI routes

RoutePurpose
/forgot-passwordRequest reset link
/reset-passwordSet new password from email link
/verify-emailResend verification

Forgot-password checks isEmailConfigured() and shows a clear error if Resend is unset.

Where to change this

WhatWhere
Send helperssrc/lib/email/index.ts
Resend client & configsrc/lib/email/client.ts, config.ts
Templatessrc/lib/email/templates/
Auth email hookssrc/lib/auth/auth.ts

Better Auth — verification and reset flow.

Environment Variables — env reference.