Frameworks

How to send React Email templates

Short answer

React Email lets you write email templates as React components. It does not send anything itself: you call render() from @react-email/render to turn a component into an HTML string, render it again with plainText: true for the text version, and pass both to an email API or an SMTP library such as Nodemailer. Rendering happens on your server, so any provider that accepts HTML works.

Last checked 16 November 2026

React Email is a library for writing email templates as React components. It handles the hard parts of email HTML, such as table layouts and inline styles, but it does not deliver mail. The flow is always the same: write a component, call render() to turn it into an HTML string on your server, then send that string through an email API or SMTP.

Install React Email

New projects install the react-email package, which contains the components, along with React. Add @react-email/render for the render() function:

npm install react-email @react-email/render react react-dom

Older projects imported components from @react-email/components. That package is now marked as no longer supported on npm, and the same components are exported from react-email. render() is also re-exported from react-email, so either import works; this guide imports it from @react-email/render.

Write a template

A template is a normal React component. Props become the variables you fill in for each recipient:

// emails/welcome.tsx
import { Body, Button, Container, Head, Html, Preview, Text } from 'react-email';

type Props = { name: string; loginUrl: string };

export default function WelcomeEmail({ name, loginUrl }: Props) {
  return (
    <Html lang="en">
      <Head />
      <Preview>Your Acme account is ready</Preview>
      <Body style={{ fontFamily: 'Arial, sans-serif', backgroundColor: '#ffffff' }}>
        <Container style={{ maxWidth: '560px', padding: '24px' }}>
          <Text>Hi {name},</Text>
          <Text>Your account is ready. Sign in to finish setting up.</Text>
          <Button
            href={loginUrl}
            style={{ backgroundColor: '#111827', color: '#ffffff', padding: '12px 20px' }}
          >
            Sign in
          </Button>
        </Container>
      </Body>
    </Html>
  );
}

Preview sets the short line most inboxes show next to the subject. Keep styles inline as above: many email clients strip <style> blocks or ignore them.

Render to HTML and plain text

render() takes a React element and returns a Promise that resolves to a string. Pass { plainText: true } to get a text version of the same template:

import { render } from '@react-email/render';
import WelcomeEmail from './emails/welcome';

const element = <WelcomeEmail name="Sam" loginUrl="https://acme.com/login" />;

const html = await render(element);
const text = await render(element, { plainText: true });

Always await it. Older versions of React Email had a synchronous render(), and code copied from that era sends the literal text [object Promise].

The file that calls render() contains JSX, so it must be a .tsx or .jsx file compiled by your framework or run with a tool such as tsx. If you would rather avoid JSX at the call site, use React.createElement(WelcomeEmail, { name: 'Sam', loginUrl }).

Option 1: send the HTML through an email API

The rendered strings go into a normal API request. This example uses Mailcandor’s REST API, which accepts html and text side by side:

import { render } from '@react-email/render';
import WelcomeEmail from './emails/welcome';

export async function sendWelcome(to: string, name: string) {
  const element = <WelcomeEmail name={name} loginUrl="https://acme.com/login" />;

  const res = await fetch('https://api.mailcandor.com/v1/emails', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.MAILCANDOR_KEY}`,
      'Content-Type': 'application/json',
      'Idempotency-Key': `welcome-${to}`,
    },
    body: JSON.stringify({
      from: 'Acme <hello@acme.com>',
      to,
      subject: 'Welcome to Acme',
      html: await render(element),
      text: await render(element, { plainText: true }),
    }),
  });

  if (!res.ok) {
    const { error } = await res.json();
    throw new Error(`${error.type}: ${error.message}`);
  }
  return (await res.json()).id;
}

Mailcandor does not render React for you: it receives finished HTML, like most email APIs. Some providers accept a React element directly in their SDK, but under the hood the SDK calls render() for you in the same way. Doing it yourself means the template works with any provider.

The Idempotency-Key header means a retry after a network timeout returns the first response instead of sending a second welcome email.

Option 2: send the HTML with Nodemailer over SMTP

If your app already sends through SMTP, pass the rendered strings to Nodemailer:

import nodemailer from 'nodemailer';
import { render } from '@react-email/render';
import WelcomeEmail from './emails/welcome';

const transport = nodemailer.createTransport({
  host: 'smtp.mailcandor.com',
  port: 465,
  secure: true,
  auth: { user: 'mailcandor', pass: process.env.MAILCANDOR_KEY },
});

const element = <WelcomeEmail name="Sam" loginUrl="https://acme.com/login" />;

await transport.sendMail({
  from: 'Acme <hello@acme.com>',
  to: 'sam@example.com',
  subject: 'Welcome to Acme',
  html: await render(element),
  text: await render(element, { plainText: true }),
});

The Nodemailer SMTP guide covers ports, connection pooling and attachments.

Using React Email in Next.js

In Next.js, render inside a route handler or a server action, never in a client component, because the send needs your secret key. The Next.js email guide shows both patterns. Keep templates in a folder such as emails/ outside app/ so they are not treated as routes.

Common problems

  • The email body is [object Promise]: you forgot to await the render() call.
  • Styles missing in Gmail or Outlook: use inline style props or React Email’s Tailwind component rather than a stylesheet.
  • “Cannot use JSX” errors: the file that renders the template is not compiled as .tsx or .jsx.

Which should you choose?

Email API SMTP (Nodemailer)
Rendering render() in your code render() in your code
Extra packages None beyond React Email nodemailer
Serverless and edge Works everywhere fetch works Node.js runtime only
Delivery events Webhooks with an email id Usually none

Rendering is identical either way, so the choice comes down to transport. For new apps, the API route is less to run; for existing SMTP setups, keep SMTP and swap the HTML.

Before you send: verify your domain

A well-built template still lands in spam if the sending domain is not authenticated. Add your domain with your provider, publish the SPF, DKIM and DMARC records it gives you, and wait for verification. The SPF, DKIM and DMARC guide explains each record.

Questions

Does React Email send emails?

No. React Email builds and renders templates. You still need an email API or SMTP server to deliver the HTML it produces.

Is render() synchronous?

No. In current versions render() returns a Promise, so you must await it. Code written for older versions that used render() without await will send "[object Promise]" as the body.

Do I still need a plain text version?

It is good practice. Some people read mail in text-only clients, and a text part next to the HTML is a normal sign of a well-formed message. render() with plainText: true produces it from the same component.

Can I use React Email outside Next.js?

Yes. It works in any Node.js code that can compile JSX, such as an Express server, a background worker or a script run with tsx.

Should I import components from @react-email/components?

Not in new projects. The components now ship in the react-email package, and @react-email/components is marked as no longer supported on npm. Existing imports keep working until you upgrade.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.