This is my research on the integration of react-email and NodeJS (express). I used mailtrap and nodemailer to mock the sending of email.
- React email does not work with NodeJS very well and would be better paired with NextJS
- Node does not recognize tsx/jsx by default, so it is not possible to import the react file into the nodejs code directly
- Found a workaround albeit less dynamic i.e. generate raw HTML output of the email's React files through
email export
command andreadfilesync
the generated html file - Let's hope there will be a good solution for this soon
To run this application locally, please follow the steps below:
- Clone the repository to your local machine:
git clone https://github.com/keiloktql/express-react-email-service
- Install the dependencies:
npm install
- Create a .env file in your project root and add your Mailtrap API Keys.
MAILTRAP_AUTH_USER=xxxxxxxxx
MAILTRAP_AUTH_PASS=xxxxxxxxx
- To start the NodeJS development server:
npm start
- To start the React Email development server:
npm run devEmail
Distributed under the MIT License. See LICENSE.txt
for more information.
Cheers!