Next.js Discord

Discord Forum

Env variables

Unanswered
wWHYSOSERIOUSs posted this in #help-forum
Open in Discord
How can I add env variabke for dev, prod and stag

I'm doing env.development, env.production, env.staging

And passing NODE_ENV=<suffix of my env file> next build

But it never picks the env file

6 Replies

Asian black bear
Hi, can you please share the code how its used, i'm facing the same issue
@Asian black bear Hi, can you please share the code how its used, i'm facing the same issue
Dotenv.config({path: .env.{process.env.NODE_ENV})
Then u need to pass node env when u do dev or build
This way you can have cystom env names
Use dotenv package