Skip to main content

Module Configuration Interface

The Nuxt Lettermint module accepts configuration options through the lettermint key in your nuxt.config.ts file. The module exposes the following TypeScript interface:
export interface ModuleOptions {
  apiKey?: string
  autoEndpoint?: boolean
}

Configuration Options

All configuration options are optional and can be set in your nuxt.config.ts file or through environment variables.
apiKey
string
default:"undefined"
Your Lettermint API key for authenticating with the Lettermint email service.If not provided here, the module will automatically look for the NUXT_LETTERMINT_API_KEY environment variable.
It’s recommended to use environment variables instead of hardcoding your API key in the config file. See Environment Variables for more details.
autoEndpoint
boolean
default:"true"
Controls whether the module should automatically create the /api/lettermint/send endpoint.When enabled (default), the module creates a ready-to-use API endpoint for sending emails from the client side using the useLettermint() composable.Set to false if you want to create your own custom endpoints with additional logic. See Auto-generated Endpoint for more details.

Basic Configuration

Add the module to your Nuxt configuration:
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-lettermint']
})

Configuration with Options

You can configure the module by adding a lettermint key to your config:
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-lettermint'],
  lettermint: {
    apiKey: 'your-api-key'
  }
})

Default Values

The module uses the following default values:
OptionDefault ValueSource
apiKey'' (empty string)Environment variable NUXT_LETTERMINT_API_KEY or configured value
autoEndpointtrueModule defaults
If no API key is provided through configuration or environment variables, the module will still load but email sending will fail. Make sure to configure your API key before attempting to send emails.

Runtime Configuration

The module automatically integrates with Nuxt’s runtime configuration system. The API key is stored securely in the server-side runtime config:
const runtimeConfig = {
  apiKey: options.apiKey || process.env.NUXT_LETTERMINT_API_KEY || '',
}
This ensures your API key is only available on the server side and never exposed to the client.

TypeScript Support

The module provides full TypeScript support with type augmentation for Nuxt’s schema:
declare module '@nuxt/schema' {
  interface RuntimeConfig {
    lettermint: {
      apiKey: string
    }
  }
  interface PublicRuntimeConfig {
    lettermint?: Record<string, never>
  }
}

Next Steps

Environment Variables

Learn how to configure the module using environment variables

Auto-generated Endpoint

Understand how the auto-generated API endpoint works

Build docs developers (and LLMs) love