1 min read
ENV files order in Next.js

Order in development mode (npm run dev):

.env (general settings)
.env.development (dev settings)
.env.local (local settings)

Order in production mode (npm start):

.env (general settings)
.env.production (production settings)
.env.local (local settings)

As you can see .env.local has the highest priority and runs in dev and prod modes as well as .env file.