Leave Localhost logoLeave LocalhostDocs
Emails

Email Overview

Leave Localhost includes a complete transactional email system built on Resend and React Email. Templates live in one place in the backend; the preview workspace renders those same templates in the browser.

Leave Localhost includes a complete transactional email system built on Resend and React Email. There is a single source for templates — the backend — and a preview workspace that renders those same templates in the browser so you can design them with live reload.

Architecture

┌─────────────────────────────────────────────────┐
│  packages/backend/convex/email/   ← SINGLE SOURCE│
│  ├── index.ts          # sendEmail() facade     │
│  └── templates/        # React Email templates  │
│      ├── emailVerificationEmail.tsx              │
│      ├── magicLinkEmail.tsx                      │
│      ├── organizationInvitationEmail.tsx          │
│      ├── passwordResetEmail.tsx                  │
│      ├── sensitiveActionVerificationEmail.tsx     │
│      └── subscriptionEmail.tsx                   │
└───────┬─────────────────────────────┬───────────┘
        │ @convex-dev/resend          │ imported by
        ▼                             ▼
┌──────────────────┐   ┌──────────────────────────────┐
│  Resend API      │   │  packages/email/ (preview)   │
│  (production)    │   │  emails/*.tsx render the     │
└──────────────────┘   │  backend templates at :3003  │
                       └──────────────────────────────┘

One Source, Two Uses

Backend Templates (packages/backend/convex/email/templates/)

These are the email templates — the only copy. Each file is a presentational JSX component plus render* helpers that produce HTML and plain text. They are rendered server-side in Convex functions using @react-email/render and sent via the Resend component.

Preview Workspace (packages/email/)

A design-time harness, not a second set of templates. Each file under packages/email/emails/ is a thin wrapper that imports the real backend component and supplies sample props, so react-email's dev server can render it in the browser. Edit the template in the backend; edit only the sample data in the wrapper. Nothing here ships to production.

Included Emails

TemplateTriggerLocation
Email verificationPassword signup or unverified sign-inemailVerificationEmail.tsx
Magic link sign-inUser signs in with magic linkmagicLinkEmail.tsx
Organization invitationAdmin invites a memberorganizationInvitationEmail.tsx
Password resetUser requests a password resetpasswordResetEmail.tsx
Sensitive action verificationStep-up verification codesensitiveActionVerificationEmail.tsx
Subscription successPayment succeedssubscriptionEmail.tsx
Subscription errorPayment failssubscriptionEmail.tsx

Environment Variables

VariableRequiredDescription
RESEND_API_KEYYesResend API key for auth and transactional email
RESEND_FROM_EMAILNoDefault sender address
RESEND_AUTH_FROM_EMAILYesSender for auth emails (verification, password reset, magic link, invitation)
RESEND_WEBHOOK_SECRETNoResend delivery tracking webhook secret

Next Reads

On this page