
A Nuxt module for sending emails using the Lettermint email service. This module provides a seamless integration with Lettermint's Node.js SDK for both server-side and client-side email sending capabilities.
Lettermint is a European transactional email service provider focused on simplicity, reliability, and developer experience. Visit Lettermint.co for more information about our email platform.
nuxt.config.tsUsing the Nuxt CLI (recommended):
npx nuxi module add lettermint
Or install manually:
# npm
npm install nuxt-lettermint
# pnpm
pnpm add nuxt-lettermint
# yarn
yarn add nuxt-lettermint
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-lettermint']
})
First, get your API key from Lettermint:
Then set your API key in one of two ways:
Option A: Create a .env file in your project root (recommended):
NUXT_LETTERMINT_API_KEY=your-lettermint-api-key
Option B: Add it directly to your nuxt.config.ts:
export default defineNuxtConfig({
modules: ['nuxt-lettermint'],
lettermint: {
apiKey: 'your-api-key'
}
})
The module accepts the following configuration options:
export default defineNuxtConfig({
modules: ['nuxt-lettermint'],
lettermint: {
// Your Lettermint API key (see step 3 above for configuration options)
apiKey: 'your-api-key',
// Enable/disable the auto-generated /api/lettermint/send endpoint (default: true)
// Set to false if you want to create your own custom endpoints
autoEndpoint: true
}
})
By default, the module creates an endpoint at /api/lettermint/send for sending emails. If you prefer to create your own custom endpoints, you can disable this behavior:
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-lettermint'],
lettermint: {
autoEndpoint: false
}
})
Note: When you disable the auto-generated endpoint:
sendEmail functionuseLettermint() composable will not work unless you create a custom endpoint at /api/lettermint/send// server/api/custom-send.post.ts (optional)
import { sendEmail } from '#imports'
export default defineEventHandler(async (event) => {
const body = await readBody(event)
// Add your custom logic here
return await sendEmail(body)
})
<script setup>
const { send, sending, error } = useLettermint()
await send({
from: 'sender@example.com',
to: 'ok@testing.lettermint.co',
subject: 'Hello!',
html: '<h1>Hello World</h1>'
})
</script>
// server/api/send.post.ts
import { sendEmail } from '#imports'
export default defineEventHandler(async () => {
return await sendEmail({
from: 'hello@example.com',
to: 'ok@testing.lettermint.co',
subject: 'Welcome',
html: '<h1>Welcome!</h1>',
tags: ['welcome']
})
})
import { useLettermint } from '#imports'
const lettermint = useLettermint()
await lettermint.email
.from('sender@example.com')
.to('ok@testing.lettermint.co')
.subject('Hello')
.html('<h1>Hello</h1>')
.tag('campaign')
.send()
MIT License © 2025 Lettermint