--- title: 'Render' sidebarTitle: 'Render' description: 'Transform React components into HTML email templates.' 'og:image': 'https://react.email/static/covers/render.png' --- ## 1. Install dependencies Install package from your command line. ```sh npm npm install react-email -E ``` ```sh yarn yarn add react-email -E ``` ```sh pnpm pnpm add react-email -E ``` ## 2. Create an email using React Start by building your email template in a `.jsx` or `.tsx` file. ```jsx email.jsx import * as React from 'react'; import { Html, Button, Hr, Text } from "react-email"; export function MyTemplate(props) { return ( Some title
); } export default MyTemplate; ``` ## 3. Convert to HTML Import an existing React component and convert into a HTML string. You can use the `pretty` function to beautify the output. ```jsx import { MyTemplate } from './email'; import { render, pretty } from 'react-email'; const html = await pretty(await render()); console.log(html); ``` This will generate the following output: ```html

Some title


Click me ``` When running in the browser, to properly support Safari and browsers running on iOS, you will need to polyfill the [ReadableByteStreamController API](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController#browser_compatibility). We recommend [npm i web-streams-polyfill](https://www.npmjs.com/package/web-streams-polyfill). It can be applied as follows in some sort of root file for your website: ```jsx import "web-streams-polyfill/polyfill"; ``` ## 4. Convert to Plain Text Plain text versions of emails are important because they ensure that the message can be read by the recipient even if they are unable to view the HTML version of the email. This is important because not all email clients and devices can display HTML email, and some recipients may have chosen to disable HTML email for security or accessibility reasons. Here's how to convert a React component into plain text. ```jsx import { MyTemplate } from './email'; import { toPlainText, render } from 'react-email'; const html = await render(); const text = toPlainText(html); console.log(text); ``` This will generate the following output: ``` Some title --- Click me [https://example.com] ``` ### Exclude content from plain-text output Add `data-skip-in-text="true"` to an element to exclude the element and its contents when using `toPlainText()`. This does not exclude the element from the HTML output. ```jsx import { Html, Section, Text } from 'react-email'; export function MyTemplate() { return ( This content appears in both outputs.
This content appears only in the HTML output.
); } ``` The plain-text output will be: ```text This content appears in both outputs. ``` ## Options Beautify HTML output Generate plain text version `html-to-text` [options](https://github.com/html-to-text/node-html-to-text/tree/master/packages/html-to-text#options) used for rendering