- 1971: The first email ever sent on the ARPANET system, though it wasn't called "email" yet.
- 1978: A computerized interoffice mail system was invented called, EMAIL.
- 1992: Multipurpose Internet Mail Extension (MIME) made email much more flexible, supporting text in character sets other than ASCII.
- 1996: Webmail clients starting to gain popularity, and with it came support for HTML in emails.
- 2010: iPhone 4 is released and responsive emails become necessary.
Even with emails supporting HTML since 1996, there are still only a subset of HTML tags that are supported by email clients. The support for certain tags and attributes even varies from one email client to another.
Check out caniemail.com to see what clients support which tags.
With inconsistent support, making responsive emails becomes a challenge.
Created in 2015 by Mailjet, MJML had one objective, to abstract away the complexity of responsive emails.
MJML allows you to write high-level code with reusability and extensibility in mind.
The MJML engine is actually built in React for its high composability.
Much like React, MJML allows you to create custom components. The syntax is very similar to writing class components in React, but the developer experience is not great. For example, the render
has to be written as a string:
public render(): string {
return `
<span ${this.htmlAttributes({ style: 'bubble' })}>
${this.getAttribute('number')}
</span>
`;
}
Even trying to render other MJML components in your custom component is not straight forward.
public render(): string {
return `
${this.renderMJML(`
<mj-button
href="${this.getAttribute('href')}"
border-radius="4px"
>
${this.getContent()}
</mj-button>
`)}
`;
}
In 2018, MJML published the first version of mjml-react, an npm package that made it even easier to work with their components.
mjml
and mjml-react
are meant to be run inside a node.
If you want to compile mjml
from within a browser, try out mjml-browser.
mjml-react
works with that library.
npm i mjml mjml-react
npm i -D @types/mjml-react
<Mjml>
<!-- Root of every template -->
<MjmlHead>
<!-- Similar to <head> HTML tag -->
</MjmlHead>
<MjmlBody>
<!-- Similar to <body> HTML tag -->
</MjmlBody>
</Mjml>
This is a Next.js project bootstrapped with create-next-app
.
First, run the development server:
npm run dev
# or
yarn dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.tsx
. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts
.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.