.env Files
Create .env files in your project root:
VOLT_API_URL=https://api.example.com
VOLT_DEBUG=trueOnly variables prefixed with VOLT_ are exposed to client code by default.
Accessing Variables
console.log(import.meta.env.VOLT_API_URL)
console.log(import.meta.env.MODE) // "development" or "production"
console.log(import.meta.env.DEV) // true/false
console.log(import.meta.env.PROD) // true/falseEnv Prefix
Configure env_prefix when migrating from Vite or when your app already uses a different public-env naming convention:
config :volt, env_prefix: "VITE_"Multiple prefixes are also supported:
config :volt, env_prefix: ["VOLT_", "PUBLIC_"]File Loading Order
Files are loaded in order, with later files overriding earlier ones:
.env.env.local.env.{mode}(e.g..env.production).env.{mode}.local
The mode defaults to "production" for mix volt.build and "development" for the dev server. Override with --mode.
Security
Environment variables are embedded into the built JavaScript at compile time. Never put secrets or API keys in variables matching env_prefix — they will be visible in the client bundle.