This boilerplate uses environment variables for configuration. All sensitive credentials and environment-specific settings should be stored in .env files.
cp .env.example .env.env files to version control. The .gitignore file already excludes them.| Variable | Required | Scope | Description |
|---|---|---|---|
NUXT_PUBLIC_SITE_URL | ✅ | Public | Your site's public URL |
NUXT_PUBLIC_SITE_NAME | ✅ | Public | Site name (emails, meta tags) |
NUXT_PUBLIC_SITE_DOMAIN | ✅ | Public | Domain name (email sender) |
DATABASE_URL | ✅ | Server | PostgreSQL connection string |
RESEND_API_KEY | ✅ | Server | Resend API key for emails |
BETTER_AUTH_SECRET | ✅ | Server | Secret for signing auth tokens |
BETTER_AUTH_URL | ✅ | Server | Base URL for authentication |
SUPPORT_FORM_TARGET_EMAIL | ⚪ | Server | Support form recipient |
STRIPE_SECRET_KEY | ⚪ | Server | Stripe secret key |
NUXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | ⚪ | Public | Stripe publishable key |
STRIPE_WEBHOOK_SECRET | ⚪ | Server | Stripe webhook signing secret |
OPENAI_API_KEY | ⚪ | Server | OpenAI API key |
ANTHROPIC_API_KEY | ⚪ | Server | Anthropic API key |
GROK_API_KEY | ⚪ | Server | Grok / xAI API key |
IPINFO_TOKEN | ⚪ | Server | IPinfo geolocation token |
NUXT_PUBLIC_UMAMI_ID | ⚪ | Public | Umami website ID |
NUXT_PUBLIC_UMAMI_HOST | ⚪ | Public | Umami host URL |
NUXT_PUBLIC_VERCEL_ANALYTICS | ⚪ | Public | Enable Vercel Analytics |
# Your site's public URL
NUXT_PUBLIC_SITE_URL="http://localhost:3000"
# Site name (used in emails, meta tags, etc.)
NUXT_PUBLIC_SITE_NAME="Your App Name"
# Domain name (used in email sender addresses)
NUXT_PUBLIC_SITE_DOMAIN="yourdomain.com"
# PostgreSQL connection string
DATABASE_URL="postgresql://user:password@localhost:5432/database"
Format: postgresql://[user]:[password]@[host]:[port]/[database]
# Resend API key for sending emails
RESEND_API_KEY="re_..."
# Better Auth secret key (generate with: openssl rand -base64 32)
BETTER_AUTH_SECRET="your-secret-key-here"
# Base URL for authentication
BETTER_AUTH_URL="http://localhost:3000"
BETTER_AUTH_SECRET to version control. Keep it secure and regenerate it if exposed.# Email address to receive support form submissions
SUPPORT_FORM_TARGET_EMAIL="support@yourdomain.com"
# Stripe secret key (server-side)
STRIPE_SECRET_KEY="sk_test_..."
# Stripe publishable key (client-side)
NUXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="pk_test_..."
# Webhook signing secret from Stripe dashboard
STRIPE_WEBHOOK_SECRET="whsec_..."
auth or authless) is configured in app/config/payments.config.ts. See the payments integration guide for Stripe setup.# OpenAI API key for GPT models
OPENAI_API_KEY="sk-..."
# Anthropic API key for Claude models
ANTHROPIC_API_KEY="sk-ant-..."
# Grok / xAI API key
GROK_API_KEY="xai-..."
# IPinfo API token for IP geolocation
IPINFO_TOKEN="your_token"
# Umami Analytics (both required to enable)
NUXT_PUBLIC_UMAMI_ID="your-website-id"
NUXT_PUBLIC_UMAMI_HOST="https://cloud.umami.is"
# Vercel Analytics (set to any truthy value to enable)
NUXT_PUBLIC_VERCEL_ANALYTICS="true"
Nuxt uses specific prefixes for environment variables:
NUXT_PUBLIC_*Variables with this prefix are exposed to the client-side:
# ✅ Accessible in browser
NUXT_PUBLIC_SITE_URL="https://example.com"
NUXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="pk_test_..."
Access in components:
<script setup>
const config = useRuntimeConfig()
console.log(config.public.siteUrl) // Works in browser
</script>
NUXT_PUBLIC_ for secrets! These are exposed to the browser and visible in the source code.Variables without a special prefix are server-side only:
# ✅ Only accessible on server
DATABASE_URL="postgresql://..."
STRIPE_SECRET_KEY="sk_test_..."
RESEND_API_KEY="re_..."
Access only in server code:
// ✅ Works in server/api routes
const config = useRuntimeConfig()
console.log(config.stripeSecretKey)
// ❌ Returns undefined in browser
All environment variables are mapped to runtime config in nuxt.config.ts.
In server code:
export default defineEventHandler(event => {
const config = useRuntimeConfig()
// Access server-only variables
const dbUrl = config.databaseUrl
const stripeKey = config.stripeSecretKey
// Access public variables
const siteUrl = config.public.siteUrl
})
In client code:
<script setup>
const config = useRuntimeConfig()
// ✅ Public variables work
console.log(config.public.siteUrl)
// ❌ Server variables are undefined
console.log(config.stripeSecretKey) // undefined
</script>
You can create different .env files for each environment:
.env - Local development.env.staging - Staging environment.env.production - Production environmentAdd environment variables in the Vercel dashboard:
Add in Netlify dashboard or netlify.toml:
[context.production.environment]
NUXT_PUBLIC_SITE_URL = "https://yourdomain.com"
Use environment variables in docker-compose.yml:
version: '3'
services:
app:
build: .
environment:
- DATABASE_URL=${DATABASE_URL}
- NUXT_PUBLIC_SITE_URL=${NUXT_PUBLIC_SITE_URL}
Or use an .env file:
services:
app:
env_file:
- .env.production
.env files - already excluded in .gitignore.env=# ❌ Wrong
VARIABLE = "value"
# ✅ Correct
VARIABLE="value"
Add NUXT_PUBLIC_ prefix:
# ❌ Not accessible in browser
SITE_URL="https://example.com"
# ✅ Accessible in browser
NUXT_PUBLIC_SITE_URL="https://example.com"
Clear Nuxt cache and restart:
rm -rf .nuxt
pnpm dev