If you're using a /src folder structure, remember that .env* files must be placed in the , not inside /src . Next.js loads environment files only from the parent folder.
# .env.local DATABASE_URL=postgres://user:password@localhost:5432/mydevdb API_KEY=local_development_secret_key_12345 NEXT_PUBLIC_API_URL=http://localhost:3000 Use code with caution. 3. Secure Your File (Crucial Step) .env.local
NEXT_PUBLIC_APP_URL="http://localhost:3000" NEXT_PUBLIC_POSTHOG_KEY="phc_..." If you're using a /src folder structure, remember that
.env.local → .env
: Your local machine's universal override. It overrides everything below it, regardless of whether you are running a development or production build locally. .env.local
# Local Database Credentials DB_HOST=localhost DB_USER=root DB_PASS=mysecretpassword