Environment Variables
Addfox supports environment variables via .env files that can be safely used in client-side code.
Basic Usage
Create a .env file in the project root:
Default Prefix
Addfox only exposes environment variables starting with ADDFOX_PUBLIC_ by default:
Scope
Environment variables are injected into all client code entries:
- background — Service Worker / Background script
- content — Content Script
- popup — Popup page
- options — Options page
- sidepanel — Side panel
- devtools — Developer tools
:::tip Server vs Client
process.env.*inmanifestconfig is resolved at build time (server-side)process.env.*in entry code is available at runtime (client-side) :::
Built-in Variables
Addfox automatically injects the following built-in variables (no need to define in .env):
Different Environments
Development
Create .env.development:
Production
Create .env.production:
Environment File Priority
.env.{mode}.local— Local specific mode (highest priority, not committed to Git).env.{mode}— Specific mode.env.local— Local environment (not committed to Git).env— Default (lowest priority)
Complete Example
Notes
- Environment variable values are always strings
- Booleans need manual conversion:
process.env.ADDFOX_PUBLIC_DEBUG === "true" - Restart dev server after modifying
.envfiles - Don't use non-
ADDFOX_PUBLIC_prefixed variables in client code, they will beundefined

