Your project can consume variables declared in your environment as if they were declared locally in your JS files. By default you will have NODE_ENV defined for you, and any other environment variables starting with NEXT_PUBLIC_.
Adding environment variables
To define permanent environment variables, create a file called .env in the root of your project:
NEXT_PUBLIC_NOT_SECRET_CODE=abcdef
Note: You need to restart the development server after changing .env files.
Accessing environment variables
Environment variables will be defined for you on process.env. For example, having an environment variable named NEXT_PUBLIC_NOT_SECRET_CODE will be exposed in your JS as process.env.NEXT_PUBLIC_NOT_SECRET_CODE.
if (process.env.NODE_ENV !== 'production') {
// do something
}