.env File Precedence Playground

The notes on Dodi’s bench: .env, .env.local, .env.[mode], .env.[mode].local, and a variable from the shell. Change the mode and the files: whose value wins?…

Why it matters

"The value differs from what I wrote in .env" almost always means another file read later, a different mode (vite build = production), or a shell variable from CI. Knowing the order makes a strange value traceable, and knowing *.local keeps secrets out of git.

The key idea

.env < .env.local < .env.[mode] < .env.[mode].local < shell

Common mistakes

Try it in this playground