# Email Templates (React-Email) **Package:** `packages/mail/src/templates-react/` **Status:** active (Phase 10 task #75) **Replaces:** `packages/mail/src/templates/transactional.ts` (deprecated) ## Overview Transactional emails are React components. Every template is rendered deterministically to `{ html, text }` via `react-dom/server` and delivered through the standard Mailjet/queue provider chain. We chose React components over the legacy string-template approach for three reasons: 1. **XSS-safety by default** — React escapes interpolated values, so we cannot accidentally forget an `escapeHtml` call when a new prop is introduced. The old monolithic file had a recurring audit finding around manual escaping. 2. **Component reuse** — header, footer, button, info-box, and eyebrow are shared across templates. Brand-theming threads through a single `MailBrand` prop instead of token-replacement on raw HTML strings. 3. **Live preview** — `pnpm --filter @hivegrid/mail preview` boots a local HTTP server that renders every template with realistic sample data so designers can iterate without triggering live email sends. ## Adding a new template 1. **Create the component** in `packages/mail/src/templates-react/transactional/.tsx`. Accept a `brand: MailBrand` prop plus the data the template needs. Compose with `TransactionalScaffold` for the standard layout. Avoid `dangerouslySetInnerHTML` — it is banned by code review. 2. **Validate URLs** — every CTA must go through `