@vuemaildev/nuxt module lets Nitro, the server of Nuxt, import emails written as single file components,
so your server routes can render them with render and send them with any email provider.
It works with Nuxt 4 (and Nuxt 3.13 or later).
1. Install dependencies
Install Vuemail and its Nuxt module, and the preview app as a dev dependency.2. Add the module
Add@vuemaildev/nuxt to the modules of your nuxt.config.ts:
nuxt.config.ts
vuemail key:
object
Options for the compiler of the single file components Nitro bundles, the emails your server
routes import. They are the options of unplugin-vue.
3. Write your emails
Create anemails folder at the root of your project, next to app and server. It’s where
email dev looks for emails by default, so the preview and your server routes use the same files.
emails/welcome.vue:
emails/welcome.vue
4. Render and send it from a server route
Import the email in a server route, render it into HTML and plain text, and send it. This example uses Resend, but any of the integrations works the same way.NUXT_RESEND_API_KEY environment variable:
nuxt.config.ts
server/api/send.post.ts
~~ is the root of your project in Nuxt, so ~~/emails/welcome.vue points to the emails folder
whether the route is in server/api or deeper.5. Preview your emails
Add a script for the preview. Nuxt’s development server runs on port 3000, which is the default ofemail dev too, so give the preview another one:
package.json
nuxt dev and visit localhost:3001 to see your emails
change as you edit them.
Tailwind CSS 4
If your app uses Tailwind CSS 4, with@tailwindcss/vite, keep it as it is:
nuxt.config.ts
Tailwind component of your emails works on its own: it compiles the
classes an email uses, with Tailwind CSS 4, and inlines them while the email renders. It doesn’t read
the stylesheet of your app, so to use your design tokens in emails too, pass them to its theme prop:
emails/theme.ts
emails/welcome.vue
Next steps
Try adding these other components to your email.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.