Once you have mastered the basics, you can explore advanced techniques that leverage the full power of .env.development.
To prevent your project from descending into "environment variable hell," follow these battle-tested principles.
Install dotenv:
npm install dotenv
Create config.js:
const path = require('path'); require('dotenv').config( path: path.join(__dirname, `.env.$process.env.NODE_ENV`) );
console.log(.env.developmentLoading config for: $process.env.NODE_ENV); module.exports = ...process.env ;
Run your app:
NODE_ENV=development node server.js
// Loads .env.development
# .env.development
API_URL=http://localhost:3000
DEBUG=true
SECRET_KEY=dev_secret_123 # never reuse production secrets
PORT=4000
Most modern frameworks (React with Vite, Next.js, Vue, Node.js with dotenv, Django, Laravel, etc.) support the following file precedence:
echo "API_BASE=/api" >> .env.development echo "LOG_LEVEL=debug" >> .env.development Once you have mastered the basics, you can
CRA popularized the pattern of .env.development. It automatically loads:
Important caveat: In React apps (and most frontend frameworks), environment variables must be prefixed with REACT_APP_ (or VITE_, NEXT_PUBLIC_) to be exposed to the browser. Create config
# .env.development
REACT_APP_API_URL=http://localhost:3001
REACT_APP_ENABLE_MOCKS=true
Our Use of Cookies
Resy uses cookies on this website for non-essential purposes. They help us understand how you use our website, personalize content and improve our online marketing. By clicking Accept, you agree that we and our partners may store and access cookies on your device for these purposes. You may change your preference at any time and find more information about how cookies work by going to the "Set Cookie Preferences" section in our cookie policy.