This project is cool, but doesn't solve the fundamental issue that CSS support in email clients is just very poor.
The first one, definitely! The first one shows the structure of the document and places the button in context. I cant actually tell that the second example is equivalent, since there's no "rest of the document" or if there is it's done by magic behind the scenes.
Edit: I don't want to come off as too harsh on this project, this example is relatively simple so it probably doesn't show off the power of programming your email templates as code.
I can see that a few other people already brought up MJML so I hope I can have some value added but basically MJML is fanatical about making sure all their changes are supported on a very wide range of email clients. They have hundreds of contributors and 10k+ starts on Github all fixing bugs and compatibility. The project has 2000+ commits. Any new framework that comes out is going to have a lot of catching up to do.
When I use MJML I feel very confident my email will work on many different email clients. And even be responsive.
Another tip, I highly recommend a CSS minifier which inlines styles to fix a variety of CSS priority issues.
Even Gmail/Outlook/Yahoo users may disable js and/or HTML when reading mail.
To me, the first one, but I’m not convinced JSX is a good idea anywhere and I’ve been writing HTML for 30 years.
Not sure if the framework is as advanced. But, seems to solve a lot of basic issues. Surprising that providers like sparkpost or ses are not able to solve generation at scale problem with templates.
Lot's of cool follow-on value-adds you can do once your emails are in JS like this. Like writing test cases to validate that none of your emails are susceptible to HTML injection. Or writing tests about never exceeding Gmail's 100kb limit. Or rendering your emails in Storybook.
But our Emails had to replicate other teams designs 1:1 pixel perfect. So we mostly used the same code blocks.
I needed some sort of framework that would organize those code blocks and jsx was perfect. I generated twig templates out of the JSX and used php to send the emails.
E-mail clients by and large show html properly too.
A few rules:
1. Inline css of course
2. Use pixels as units
3. Don’t get too fancy.
I tuned out as soon as I read the word. “React”.
The problem with library is that they don’t go well across language, you need to call an api. (I use Java)
As of today, most email client understand the basic css.