env file
ID=123
I am able access this variable inside my pages/index.js file by
${process.env.ID}
but when I am trying same in my _app.js file its giving undefined, can anyone please suggest me how I can access this inside my _app.js file.
in next.config.js, define
env: { ID: process.env.ID },
You can use process.env but for security reasons the vars need to start with NEXT_PUBLIC_ (explained here).
In the .env,
NEXT_PUBLIC_ID=123
In the _app.js (or any front-end code),
process.env.NEXT_PUBLIC_ID