Skip to main content
General
Email

Overview

Understand the shipped Resend and React Email integration.

Open MarkdownFull AI corpusFeedback

The starter kit uses Resend for delivery and React Email for typed email templates. Both editions ship the same email API under lib/email/.

How email flows through the application

  1. A product flow calls an exported function from lib/email/emails.ts.
  2. That function renders a React Email component to HTML and plain text.
  3. lib/email/resend.ts sends both versions through Resend.
  4. Transient failures are retried and final failures are logged.

This separation keeps provider credentials out of templates and gives each message a typed input contract.

Connected product emails

The following messages are connected to shipped application flows:

FlowTrigger
Verify email addressPassword signup through Better Auth
Password resetBetter Auth password-reset request
Confirm email changeBetter Auth email-change request
Organization invitationCreating an invitation through the organization plugin
Contact formA successful contact-form submission
Payment failedA handled Stripe invoice failure webhook
Subscription canceledA handled Stripe subscription deletion webhook
Trial endingA handled Stripe trial-ending webhook
Dispute receivedA handled Stripe dispute webhook

lib/email/templates/revoked-invitation-email.tsx and its sending function are included for customization, but the shipped invitation-revocation action does not call it automatically. Wire it into that action if your product should notify the recipient.

Send a custom email

Use the generic transport for a one-off message:

lib/actions/send-custom.ts
import { sendEmail } from '@/lib/email';

await sendEmail({
  recipient: 'user@example.com',
  subject: 'Welcome!',
  html: '<h1>Welcome to our platform!</h1>',
  text: 'Welcome to our platform!'
});

For a reusable product email, create a typed React Email template and an exported rendering function in lib/email/emails.ts. This guarantees that HTML and plain-text versions are generated consistently.