Skip to main content

Overview

The recommended way to configure the Nuxt Lettermint module is through environment variables. This approach keeps sensitive credentials secure and makes it easy to use different API keys across development, staging, and production environments.

Available Environment Variables

NUXT_LETTERMINT_API_KEY
string
required
Your Lettermint API key for authenticating with the email service.This is the primary configuration option for the module. When set, the module will automatically use this API key for all email operations.

Setting Up Environment Variables

Local Development

Create a .env file in your project root:
.env
NUXT_LETTERMINT_API_KEY=your-lettermint-api-key
Nuxt automatically loads environment variables from .env files. Make sure your .env file is in your project root directory.

Production Deployment

For production environments, set the environment variable through your hosting platform:
# Add to your Vercel project settings
NUXT_LETTERMINT_API_KEY=your-production-api-key

Getting Your API Key

To obtain your Lettermint API key:
  1. Visit the Lettermint Dashboard
  2. Select your project from the list
  3. Navigate to the API settings or tokens section
  4. Copy your API token
If you don’t have a Lettermint account yet, sign up at lettermint.co to get started.

Configuration Priority

When both an environment variable and a config option are provided, the module follows this priority order:
  1. Direct config value in nuxt.config.ts (lettermint.apiKey)
  2. Environment variable (NUXT_LETTERMINT_API_KEY)
  3. Empty string (default fallback)
Here’s how the module resolves the API key:
const runtimeConfig = {
  apiKey: options.apiKey || process.env.NUXT_LETTERMINT_API_KEY || '',
}

Complete Example

1

Create .env file

Create a .env file in your project root:
.env
NUXT_LETTERMINT_API_KEY=lm_1234567890abcdef
2

Configure Nuxt

Add the module to your nuxt.config.ts:
nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-lettermint'],
  lettermint: {
    // API key is automatically loaded from environment
  }
})
3

Add to .gitignore

Ensure your .env file is in .gitignore:
.gitignore
# Environment variables
.env
.env.*
!.env.example
4

Create .env.example

Create a template for other developers:
.env.example
# Get your API key from https://dash.lettermint.co/projects
NUXT_LETTERMINT_API_KEY=

Security Best Practices

Never commit your API keys to version control! Always use environment variables for sensitive credentials.
Follow these security guidelines:
Store your API keys in a .env file and add it to .gitignore. This prevents accidentally committing sensitive data.
Create separate API keys for development, staging, and production. This allows you to rotate keys without affecting other environments.
Avoid putting API keys directly in your nuxt.config.ts or source code. Always use environment variables.
❌ Bad
lettermint: {
  apiKey: 'lm_1234567890abcdef' // Never do this!
}
✅ Good
lettermint: {
  // API key loaded from NUXT_LETTERMINT_API_KEY
}
In your Lettermint dashboard, configure API keys with the minimum required permissions for their use case.
Periodically rotate your API keys, especially if you suspect they may have been exposed.

Troubleshooting

Make sure:
  • Your .env file is in the project root
  • The variable name is exactly NUXT_LETTERMINT_API_KEY
  • You’ve restarted your Nuxt development server after creating/modifying the .env file
Use .env.development and .env.production files, or configure environment variables directly in your hosting platform.
For testing, you can use Lettermint’s test email address [email protected] as the recipient with a valid API key.

Next Steps

Configuration Setup

Learn about all available configuration options

Auto-generated Endpoint

Configure the auto-generated API endpoint

Build docs developers (and LLMs) love