Installation
Get up and running with Nuxt Email Renderer in your Nuxt.js project in just a few minutes.
Prerequisites
Before installing, make sure you have:
- Node.js version 20.19 or higher
- Nuxt 4.1 or higher
- Package manager: npm, yarn, pnpm, or bun
Automatic Installation (Recommended)
To get started, add nuxt-email-renderer to your project:
npx nuxt@latest module add nuxt-email-renderer
Manual Installation
Install the Module
Add nuxt-email-renderer to your project:
npm install nuxt-email-renderer
yarn add nuxt-email-renderer
pnpm add nuxt-email-renderer
bun add nuxt-email-renderer
Add to Nuxt Config
Add the module to your nuxt.config.ts:
export default defineNuxtConfig({
modules: ["nuxt-email-renderer"],
});
Create Email Templates Directory
Create an email templates directory in your project. You can choose either location based on your Nuxt version and preference:
mkdir -p app/emails
Your project structure should now look like:
your-nuxt-project/
├── app/
│ └── emails/ # 📧 Email templates directory (Nuxt 4)
├── pages/
├── components/
├── nuxt.config.ts
└── package.json
mkdir emails
Your project structure should now look like:
your-nuxt-project/
├── emails/ # 📧 Email templates directory
├── pages/
├── components/
├── nuxt.config.ts
└── package.json
app/emails (Nuxt 4 structure) first, then falls back to emails (root directory) for backward compatibility.Create Your First Email Template
Create a simple welcome email template:
<script setup lang="ts">
interface Props {
userName: string;
confirmationUrl: string;
}
defineProps<Props>();
</script>
<template>
<EHtml>
<EHead />
<EBody>
<EContainer>
<EHeading>Welcome {{ userName }}!</EHeading>
<EText>
Thank you for joining our platform. We're excited to have you on
board!
</EText>
<EButton :href="confirmationUrl"> Confirm Your Account </EButton>
</EContainer>
</EBody>
</EHtml>
</template>
Configuration Options
Customize the module behavior in your nuxt.config.ts:
export default defineNuxtConfig({
modules: ["nuxt-email-renderer"],
nuxtEmailRenderer: {
// Custom emails directory (default: auto-detects app/emails or emails)
emailsDir: "/src/email-templates",
// Enable/disable Nuxt DevTools integration (default: true)
devtools: true,
// Enable/disable ECodeBlock + Shiki code highlighting (default: true)
codeHighlighting: true,
// CSS files (relative to project root) injected into every email template
globalCss: ["assets/css/variables.css"],
},
});
emailsin yoursrcDir(app/emailsby default) - checked firstemailsin the project root - fallback
emailsDir if you want to use a custom location.Configuration Reference
| Option | Type | Default | Description |
|---|---|---|---|
emailsDir | string | - | Directory where email templates are stored, relative to the project root. Without it, the module auto-detects <srcDir>/emails or emails |
devtools | boolean | true | Enable Nuxt DevTools integration |
codeHighlighting | boolean | true | Enables ECodeBlock and Shiki highlighting. Set to false to exclude both from build output when unused. |
globalCss | string[] | [] | Paths to CSS files (relative to project root) injected into every email as a <style> tag. Use to share CSS variables, resets, or fonts across all templates. |
The resolved module options, including the absolute email templates directory, are kept in private server runtime config. They are not available through runtimeConfig.public.nuxtEmailRenderer in the browser. If your client previously read a module option from that field, add the specific client-safe value your app needs to its own runtimeConfig.public key.
Server-Side Rendering
The module provides the renderEmailComponent function for rendering email templates in your server-side code. See the Usage guide for examples.
Next Steps
Now that you have Nuxt Email Renderer installed and configured:
Troubleshooting
Common Issues
Template Not Found
If you get a "Template not found" error:
- Check that your template file is in the correct directory (
/emailsby default) - Ensure the filename matches exactly (case-sensitive)
- Verify the template is a valid
.vuefile
Component Import Issues
If email components are not recognized:
- Make sure you're using components inside the
emailsdirectory - Check that the module is properly registered in
nuxt.config.ts - Restart your development server after configuration changes
Build Errors
If you encounter build errors:
- Ensure you're using Nuxt 4.1 or higher
- Check that all email template syntax is valid Vue
- Verify TypeScript interfaces are properly defined
Getting Help
If you encounter issues:
- 📖 Check the documentation
- 🐛 Report bugs on GitHub Issues
- 💬 Ask questions in GitHub Discussions# Installation