Skip to main content
The @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
That’s all the configuration it needs. It takes one option, under the 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 an emails 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.
Then, write your first email in 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.
Keep the API key in the runtime config, so it can be set with the 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 of email dev too, so give the preview another one:
package.json
Run it next to nuxt dev and visit localhost:3001 to see your emails change as you edit them.
The files in emails/static are only served by the preview. For the images of the emails you send, use absolute URLs to files you host, like the ones in the public folder of your Nuxt app.

Tailwind CSS 4

If your app uses Tailwind CSS 4, with @tailwindcss/vite, keep it as it is:
nuxt.config.ts
The 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
Tailwind CSS detects the classes of your whole project, including the emails folder, for the stylesheet of your app. To leave the emails out of it, add @source not "../../../emails"; to app/assets/css/main.css.

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.