From MJML
- Remove the
mjmlnpm package and install@vuemaildev/vuemail - Find all MJML templates ending with the
.mjmlextension and convert these to Vue single file components with the.vueextension. - Replace MJML standard component tags with Vuemail component tags where possible, including
<Text>,<Img>,<Button>etc. - Convert custom MJML components with the
.jsextension to Vue components with the.vueextension.
From React Email
Vuemail is a port of React Email, so its components take the same props and render the same HTML. What changes is how emails are written: as Vue single file components instead of React components.-
Replace the React Email packages with the Vuemail ones, and React with Vue:
-
Rewrite each email as a
.vuefile in youremailsdirectory. Most of it maps one to one:Here’s an email written with Vuemail:emails/welcome.vue -
Keep a few differences in mind:
<style>tags can’t be written in Vue templates. Render them from<script setup>instead, with a small functional component:const Styles = () => h('style', { innerHTML: css }).- Numbers in style objects get
pxadded on Vuemail components, like in React, but not on plain elements like<td>or<p>. Prefer strings with units, like'20px'. defineOptionsis hoisted out of<script setup>, soPreviewPropshas to be written inline.- Importing
.vuefiles needs a bundler that compiles them. See compiling emails.
Image
Display an image in your email.
Link
A hyperlink to web pages or anything else a URL can address.
Divider
Display a divider that separates content areas in your email.
Preview
A preview text that will be displayed in the inbox of the recipient.