Hacker News new | ask | show | jobs
by halostatue 1352 days ago
Just use MJML (https://github.com/mjmlio/mjml) or mrml (https://github.com/jdrouet/mrml). It solves the real problems with building emails without introducing useless abstractions like JSX.
6 comments

MJML is terrific (haven't tried MRML) but why do you consider JSX to be a useless abstraction but not MJML?
Because you get 2 levels of indirection instead of 1.

If 1 does the job equally well, you should choose 1.

In fact, MJML can be used with any templating solution, so if your system already uses JSX, JSX doesn't add indirection, and you should use it.

But if your system is not, adding JSX on top has just prevents you from hacking a shell scripts that generates the email in a few lines, generating the email from whatever backend you use, or just writing the template in a free form file without anything to install.

You gain complexity, you loose flexibility.

I'm not sure what you mean by indirection in this instance. How does JSX use 2 levels?

> MJML can be used with any templating solution

Wouldn't that add complexity where JSX has less? Why use 2 systems (MJML + [templating]) when you can get away with 1 (JSX)?

> adding JSX on top has just prevents you from hacking a shell scripts

As far as I understand both are npm libraries so I can't see how one allows this where the other doesn't? Surely their application is the same usage pattern?

Agreed that MJML is great, but I wouldn't call JSX a useless abstraction. Using JSX as a templating language for MJML has real benefits, like being able to use javascript directly in templates instead of having to remember handlebars/mustache/nunjucks/etc templating syntax.

And libraries like mjml-react make it really easy.

https://github.com/wix-incubator/mjml-react/

MJML-React is awesome to use because of the JSX support: 1. you can integrate real JS without using some templatey thing, and 2. type safety with TS, helpful for auto-completion and robustness

Anyways it seems that Wix is no longer maintaining the project and Faire has taken it on: https://github.com/Faire/mjml-react

Came here to saw we use mjnl react and it's awesome to be able to wrap mjml in your own components.
if you read a bit of the jsx mail documentation you will see that it not only allows you to use jsx in emails, it does that and gives you a complete development environment with even an email client simulator for you to be your email in time real
Agreed. We use Python + Jinja to create dynamic mjml.
I'm using mjml-react which gives me:

- proper i18n with any react i18n library

- js to create complicated emails

- nicer component reuse story.

- syntax highlighting and completion when used with Typescript

- can be integrated with other nice js tools like Storybook for seeing all emails in one place and play with their props.

How is that useless?

HNers need to learn to just ask people why they use a given tech instead of dismissing it outright because the HNer likes to do things a different way.

The discourse would be much less boring.

I don't call it useless, I know the power he has, so I think he must have more competitors and we're here for that.
I'm currently integrating MJML into a React/JSX context. From my vantage point, MJML is the abstraction.

I once worked with a guy who kept looking over my shoulder and saying 'just use binary'. Nice guy, but they had to let him go.

jsx mail not only solves the compatibility issue like others do, it also has things like a mail client emulator. especially if you want to use it without being linked to a programming language, you can just use the CLI that will give you pure HTML and CSS, among that several features that were designed to improve and facilitate the creation of email templates
Early versions of MJML used JSX class components.