I have a Next Js app on Vercel and I've set various environment variables related to the database, etc, both for development and for production. All these variables work.
But I can't figure out how I can use the process.env.NODE_ENV that I use in local env in the dev build. For example, if I want to change the text logo in dev it doesn't work (in local yes, but on Vercel no)
<span>{process.env.NODE_ENV === "development" ? `${siteConfig.name} DEV` : siteConfig.name}</span>
I set the dev branch for preview.

I also tried to set these variables in this way, but of course, it doesn't work

Is that the correct way to approach this thing? How can I change, for example, the ui based on the environment? Thanks
Vercel docs state:
If the environment variable
NODE_ENVis unassigned, Next.js automatically assignsdevelopmentwhen running thenext devcommand, orproductionfor all other commands.
In your case, consider avoiding the use of NODE_ENV entirely and instead use Vercel System Variables; particularly VERCEL_ENV which tells you the Vercel Environment that the app is deployed and running on.

Running next build sets NODE_ENV=production automatically.
Since both Production and Preview deployments on Vercel run next build, they both set NODE_ENV=production automatically because next build performs production optimizations, one of those is ensuring React uses the production version.
I suggest using a different env var name for your use case such as SITE_NAME=Dev. Then you can write your code like the following:
<span>{process.env.SITE_NAME || siteConfig.name}</span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With