Quick Use
npm install @react-email/components react-email- Write emails as JSX in
./emails/ npx react-email devfor preview; pass component toresend.emails.send({react: ...})
Intro
React Email is Resend's open-source library that lets you compose transactional emails as React components — same JSX you write for the web, with email-safe primitives (Container, Section, Heading, Text, Button, Link, Img, Preview) that compile to email-client-tolerant HTML. Includes a dev preview server. Best for: any team already on React who wants typed, componentized emails without table-soup HTML. Works with: Resend, SendGrid, Postmark, AWS SES — render to HTML and pass to any provider. Setup time: 5 minutes.
Install
npm install @react-email/components react-emailA welcome email component
// emails/welcome.tsx
import { Body, Container, Head, Heading, Html, Preview, Text, Button, Link } from "@react-email/components";
interface Props { firstName: string; activationUrl: string }
export default function WelcomeEmail({ firstName, activationUrl }: Props) {
return (
<Html>
<Head />
<Preview>Welcome to TokRepo — activate your account in one click</Preview>
<Body style={{ fontFamily: "system-ui", backgroundColor: "#f6f9fc", padding: "24px" }}>
<Container style={{ background: "white", padding: "32px", borderRadius: "8px" }}>
<Heading as="h1">Welcome, {firstName} 👋</Heading>
<Text>Click below to activate your TokRepo account. The link expires in 24 hours.</Text>
<Button href={activationUrl} style={{ background: "#000", color: "#fff", padding: "12px 20px", borderRadius: "6px" }}>
Activate account
</Button>
<Text style={{ marginTop: "24px", color: "#666", fontSize: "12px" }}>
Didn't sign up? Ignore this email or <Link href="https://tokrepo.com/help">contact support</Link>.
</Text>
</Container>
</Body>
</Html>
);
}Render + send with Resend
import { Resend } from "resend";
import WelcomeEmail from "./emails/welcome";
const resend = new Resend(process.env.RESEND_API_KEY);
await resend.emails.send({
from: "TokRepo <welcome@tokrepo.com>",
to: "user@example.com",
subject: "Welcome to TokRepo",
react: WelcomeEmail({ firstName: "Jane", activationUrl: "https://tokrepo.com/a/abc123" }),
});Preview server (npx react-email dev)
npx react-email dev
# Opens http://localhost:3000 — live-reloading preview of every email in ./emails/Email-safe component cheat sheet
| Component | Replaces |
|---|---|
<Container> |
<div style="max-width: 600px"> table wrapper |
<Section> |
<table> block |
<Row> / <Column> |
Layout grid |
<Heading> |
h1-h6 with email-safe defaults |
<Button> |
Styled <a> rendering as button (avoids Outlook breaks) |
<Img> |
<img> with safe defaults (no border, block display) |
<Preview> |
Inbox preview text (renders invisibly in body) |
FAQ
Q: Does it work with Gmail dark mode? A: Yes — primitives include forced color tokens to avoid Gmail's auto color-inversion mangling brand colors. Test with the Resend dashboard's email render preview which shows light + dark side by side.
Q: Can I use Tailwind?
A: Yes — React Email supports @react-email/tailwind. Inline styles are still the most portable but Tailwind classes resolve to inline styles at render time.
Q: How do I attach files?
A: Resend's emails.send accepts an attachments: [{filename, content}] field where content is a Buffer or base64 string. React Email handles the body; Resend handles attachments.
Source & Thanks
Built by Resend. Licensed under MIT.
resend/react-email — ⭐ 16,000+