/react-emails

Create and render emails on the server with React

Primary LanguageJavaScriptMIT LicenseMIT

Generating Emails with React

This is an example project you can use to generate emails with React. You can start by reading the article here.

If you want to generate PDFs using react, check the react-pdfs repo.

Example

To provide an example as starting point, this project generates a weather forecast by using the MetaWeather API.

To generate the example email:

$ npm install
$ npm run build
$ node example/weather.js

The result html will be saved in the working directory. Here is what it looks like:

Email preview

Development

This project was bootstrapped with Create React App. See the development guide here.

Creating the email

To create the email, simply import the module and call the function with the data. It returns a promise that resolves to the full HTML template as a string.

const createEmail = require('react-emails-example');

const data = { 
  name: 'Alberto',
  title: 'Demo email',
};

createEmail(data)
  .then((html) => {
    // Send the HTML with your email service of choice
  });

LangAI

Built with ❤️ by Lang.ai