if you are using latest version of nextJs ( above 9 )
then follow these steps :
- Create a .env.local file in the root of the project.
- Add the prefix NEXT_PUBLIC_ to all of your environment variables.
eg: NEXT_PUBLIC_SOMETHING=12345
- use them in any JS file like with prefix process.env
eg: process.env.NEXT_PUBLIC_SOMETHING