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
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 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:Getting Your API Key
To obtain your Lettermint API key:- Visit the Lettermint Dashboard
- Select your project from the list
- Navigate to the API settings or tokens section
- 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:- Direct config value in
nuxt.config.ts(lettermint.apiKey) - Environment variable (
NUXT_LETTERMINT_API_KEY) - Empty string (default fallback)
Complete Example
Security Best Practices
Follow these security guidelines:Use .env files for local development
Use .env files for local development
Store your API keys in a
.env file and add it to .gitignore. This prevents accidentally committing sensitive data.Use different keys for different environments
Use different keys for different environments
Create separate API keys for development, staging, and production. This allows you to rotate keys without affecting other environments.
Never hardcode API keys
Never hardcode API keys
Avoid putting API keys directly in your
nuxt.config.ts or source code. Always use environment variables.❌ Bad
✅ Good
Restrict API key permissions
Restrict API key permissions
In your Lettermint dashboard, configure API keys with the minimum required permissions for their use case.
Rotate keys regularly
Rotate keys regularly
Periodically rotate your API keys, especially if you suspect they may have been exposed.
Troubleshooting
API key not being detected
API key not being detected
Make sure:
- Your
.envfile 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
.envfile
Different key needed per environment
Different key needed per environment
Use
.env.development and .env.production files, or configure environment variables directly in your hosting platform.Testing without a real API key
Testing without a real API key
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