DEV Community

Cover image for How to create environment variables only to be used in the development version of Nextjs?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to create environment variables only to be used in the development version of Nextjs?

Originally posted here!

To create environment variables that should be used only in the development version of your Nextjs project, you can make a file called .env.development at the root of the Nextjs project folder.

This file will be used (along with the .env if you have it defined) to take environment variables in the development version or when using the next dev command in the terminal.

For example, let's say you have an environment variable called SERVER_ID=12345 which you need to use only in the development version of your Next.js project, so we can define this environment variable in the .env.development file like this,

.env.development file

SERVER_ID = 12345;
Enter fullscreen mode Exit fullscreen mode

Feel free to share if you found this useful 😃.


Top comments (0)