Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wix-incubator/mjml-react
React component library to generate the HTML emails on the fly
https://github.com/wix-incubator/mjml-react
email email-marketing email-templates html mjml node react
Last synced: 1 day ago
JSON representation
React component library to generate the HTML emails on the fly
- Host: GitHub
- URL: https://github.com/wix-incubator/mjml-react
- Owner: wix-incubator
- License: mit
- Created: 2018-06-06T12:39:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-24T14:06:41.000Z (over 1 year ago)
- Last Synced: 2024-12-01T05:12:33.655Z (13 days ago)
- Topics: email, email-marketing, email-templates, html, mjml, node, react
- Language: JavaScript
- Homepage:
- Size: 89.8 KB
- Stars: 992
- Watchers: 85
- Forks: 50
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-email-marketing - Mjml react
- awesome-list - mjml-react - incubator | 320 | (JavaScript)
README
# mjml-react · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/wix-incubator/mjml-react/blob/master/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/wix-incubator/mjml-react/pulls)
---
## NOTICE: This project is no longer maintained. :warning:
This project is no longer maintained. There will be no more new features, fixes and releases. Feel free to fork this repository, use different build system and release this project under different name.
Known forks:
* [Faire mjml-react fork](https://github.com/Faire/mjml-react)
---
·
There is an awesome library [mjml](https://mjml.io/) with github repo here [https://github.com/mjmlio/mjml](https://github.com/mjmlio/mjml).
`MJML` is a markup language created by [Mailjet](https://www.mailjet.com/).
So in order to create emails on the fly we created a library with `React` components.## How it works
Install the required dependencies first:
```bash
npm install react react-dom mjml mjml-react
```And afterwards write a code like a pro:
```js
import {
render,
Mjml,
MjmlHead,
MjmlTitle,
MjmlPreview,
MjmlBody,
MjmlSection,
MjmlColumn,
MjmlButton,
MjmlImage,
} from "mjml-react";const { html, errors } = render(
Last Minute Offer
Last Minute Offer...
I like it!
,
{ validationLevel: "soft" }
);
```And as the result you will get a nice looking email HTML (works in mobile too!)
![preview](https://user-images.githubusercontent.com/10008149/41058394-59b8ce9e-69d2-11e8-9eb9-c294f35bae9f.png)
## Options
mjml-react sets the following MJML options when rendering to HTML:
```js
{
keepComments: false,
beautify: false,
minify: true,
validationLevel: 'strict'
}
```If you want to override these, you can pass an object to `render` as a second argument. See the [MJML docs](https://documentation.mjml.io/#inside-node-js) for the full list of options you can set.
## Extensions
```js
import {
MjmlHtml,
MjmlComment,
MjmlConditionalComment
} from 'mjml-react/extensions';Built with ... at ...
//MSO conditionals
//MSO conditionals
////
Hello World!
```## Utils
We do have also some utils for post processing the output HTML.
Because not all mail clients do support named HTML entities, like `'`.
So we need to replace them to hex.```js
import { namedEntityToHexCode, fixConditionalComment } from "mjml-react/utils";const html = "
'";
namedEntityToHexCode(html);
//'fixConditionalComment(
"",
"Hello",
"if IE"
);
//
```## Limitations
Currently `mjml` and `mjml-react` libraries are meant to be run inside a node.
## Example project
You can find an example project here
[https://github.com/wix-incubator/mjml-react-example](https://github.com/wix-incubator/mjml-react-example)