Core concepts

Environment Variables

Lunadeck supports build-time environment variables that are injected during the Web Build stage.

Setting variables

You can set environment variables in two ways:

Dashboard

  1. Go to Project Settings > Environment Variables
  2. Click Add Variable
  3. Enter the key and value
  4. Choose whether the variable is available in all environments or specific ones

Configuration file

{
  "env": {
    "NEXT_PUBLIC_API_URL": "https://api.example.com",
    "NEXT_PUBLIC_APP_VERSION": "1.2.0"
  }
}

Variable precedence

Variables are resolved in this order (highest to lowest priority):

  1. Dashboard environment variables
  2. lunadeck.config.json env field
  3. .env.production file in your project
  4. .env file in your project

Sensitive variables

Variables marked as secret in the dashboard are:

  • Encrypted at rest
  • Never logged in build output
  • Masked in the build logs UI
  • Not included in the built application bundle

Framework-specific prefixes

Most frameworks only expose variables with specific prefixes to the client:

FrameworkRequired Prefix
Next.jsNEXT_PUBLIC_
ViteVITE_
NuxtNUXT_PUBLIC_
AngularN/A (use environment.ts)