Environment variable management for Next.js
Next.js loads environment variables for server and client bundles with different rules. Secrets must stay server-only; public values use the NEXT_PUBLIC_ prefix.
Server vs public variables
Variables without NEXT_PUBLIC_ are available on the server. Anything prefixed with NEXT_PUBLIC_ is inlined into the client bundle — never put API secrets there.
# Server-only (good for secrets)
DATABASE_URL=postgresql://...
AUTH_SECRET=your_auth_secret_here
# Exposed to the browser (public only)
NEXT_PUBLIC_APP_URL=https://eanvi.comLocal development with EANVI
Store real values in an EANVI environment, then eanvi pull into a gitignored .env.local (or .env) that Next.js already understands. Teammates get the same keys without a shared zip file.
Production and preview deployments
Map each deploy target to an EANVI environment. Use CI API keys to pull or inject values at build/deploy time so preview apps never reuse production secrets.
Related resources
Try EANVI
Create a workspace, import a .env, and pull secrets from the CLI.