← All Posts
Tutorial

Building Email Templates with React in 2026

Why React for email templates

Email HTML is notoriously painful. You're writing code for rendering engines that are decades behind modern browsers — Outlook uses Microsoft Word's rendering engine, Gmail strips most CSS, and every email client has different quirks. React Email and similar libraries solve this by letting you build email templates with React components that compile to battle-tested, cross-client HTML. You write clean, composable JSX with proper TypeScript types, and the library handles the nightmare of inline styles, table-based layouts, and client-specific hacks. This means your email templates can live alongside your application code, use the same component patterns your team already knows, and be version-controlled and code-reviewed like any other code.

Setting up React Email

Install React Email in your project: npm install @react-email/components. The library provides pre-built components like Html, Head, Body, Container, Section, Text, Link, Button, and Image — each generating email-safe HTML. Create a new directory for your email templates, e.g., src/emails/. Each template is a React component that exports a default function returning JSX using React Email components. You can preview templates locally with the React Email dev server: npx email dev. This launches a browser-based preview that shows how your template renders across different email clients.

Building a welcome email template

A typical welcome email template includes a header with your logo, a greeting with the user's name, a brief description of what they can do next, a primary call-to-action button, and a footer with your company information. Using React Email components, this is straightforward JSX — Container for centering, Section for grouping, Text for paragraphs, Button for CTAs, and Img for images. The key advantage of React is composability: create reusable components for your email header, footer, and button styles, then compose them into different templates. When you update your brand colors, change it in one place and all templates update.

Rendering and sending with AISend

To send a React Email template through AISend, render it to HTML string using the render function from @react-email/render, then pass the HTML to AISend's API. You can do this at send time (dynamic rendering with user data) or at build time (pre-rendering static templates). For transactional emails like password resets, render at send time so you can include the user's name and reset link. For templates that don't change per-user, pre-render at build time for better performance. AISend accepts any valid HTML in the html field — there's no template system to learn or template IDs to manage. Your React components are your templates.

Testing and best practices

Test your email templates across clients before sending to real users. React Email's dev server shows basic previews, but for thorough testing, use services like Litmus or Email on Acid that render your template in dozens of email clients. Keep your templates simple — complex layouts break in Outlook. Use system fonts or web-safe fonts (Arial, Helvetica, Georgia) since custom fonts have limited email client support. Keep email width under 600px for mobile compatibility. Always include a plain text version for accessibility and deliverability. And test with real data — a name that's 40 characters long or an order with 50 line items might break your layout in ways you don't expect.

Ready to Send Smarter Emails?

1,000 emails/month free. No credit card required.