EUR
en
Do not put spaces around the = .
While loading priority can vary slightly by framework, the standard hierarchy from lowest priority to highest priority is:
Imagine a team of five developers working on a project. The global .env file might point to a shared staging database. However, Developer A wants to test a destructive database migration on their own machine. By adding DATABASE_URL=postgresql://localhost:5432 to their .env.local file, Developer A overrides the shared staging URL without breaking the application for the other four developers. Why .env.local Must Be Ignored by Git .env.local
# Database Configuration DATABASE_URL="postgresql://user:password@localhost:5432/mydb" # API Keys (Sensitive - Keep local only) STRIPE_SECRET_KEY="sk_test_4eC39HqLyjWDarjtT1zdp7dc" NEXT_PUBLIC_ANALYTICS_ID="UA-12345678-1" # Service URLs BACKEND_API_URL="http://localhost:4000/api" # Feature Flags ENABLE_NEW_DASHBOARD=true Use code with caution. Copied to clipboard Key Characteristics
DATABASE_URL=postgres://localhost:5432/mydb STRIPE_SECRET_KEY=sk_test_51... DEBUG=true Use code with caution. Copied to clipboard .gitignore Do not put spaces around the =
: Loaded in all environments (development, production, testing). Contains default values.
By placing .env.local of the precedence chain, the pattern ensures that any variable you set there will override the same variable from any other file. This is intentional: it allows you to test a different API endpoint or database without modifying the committed configuration. However, Developer A wants to test a destructive
You may need to prefix variables with NEXT_PUBLIC_ to make them available in the browser [5.1]. javascript
Why isn't my .env.local loading? Here are the top five mistakes.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.