In this ongoing series, I am putting together a Github Repository Template for my "Go To" front-end tech stack of Next.js, React, TypeScript etc. In this installment of the series, I will get custom environment variables into our Next.js application ...

Markdown supported · ⌘↵ to post
Hi Blaine Garrett,
Thanks for sharing a great writeup about a gnarly topic.
I have a minor correction to share. You wrote:
"Note: This hierarchy optionally goes further with
.env.developmentand.env.production(corresponding to the value of NODE_ENV)..."But they don't actually correspond to the value of NODE_ENV. Next.JS bases its decision to read from
.env.developmentvs.env.productionon one thing only: whether you start the app withnext devornext start. That's all. NODE_ENV's value is irrelevant to that bit of Next-specific logic.AFAICT you get the rest of the complicated picture right; hopefully my comment will inspire you to edit the post, or at least help ensure other readers aren't accidentally misled.
Slainte, Chris