Documentation
Email (Resend)
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
- Create a Resend account
- Create an API key (send permission)
- Add and verify your sending domain (SPF/DKIM) — or use
onboarding@resend.devfor local tests - Set env vars:
| Variable | Purpose |
|---|---|
RESEND_API_KEY | Server-only API key |
EMAIL_FROM | Sender, 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
| Trigger | Template | |
|---|---|---|
| Verification | Sign up / resend | verification-email.tsx |
| Password reset | Forgot password | password-reset-email.tsx |
| Welcome | Account created | welcome-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.tsxBuilt with @react-email/components. Edit copy and styling in the template files. Brand name: shared.tsx.
Add a new transactional email
- Create
src/lib/email/templates/your-email.tsx(useTransactionalEmailLayoutfromshared.tsx) - Export
sendYourEmail(...)fromsrc/lib/email/index.ts - 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
| Route | Purpose |
|---|---|
/forgot-password | Request reset link |
/reset-password | Set new password from email link |
/verify-email | Resend verification |
Forgot-password checks isEmailConfigured() and shows a clear error if Resend is unset.
Where to change this
| What | Where |
|---|---|
| Send helpers | src/lib/email/index.ts |
| Resend client & config | src/lib/email/client.ts, config.ts |
| Templates | src/lib/email/templates/ |
| Auth email hooks | src/lib/auth/auth.ts |
Better Auth — verification and reset flow.
Environment Variables — env reference.