Environment Variables
Learn how to configure the environment variables.
There are different options to configure environment variables in a Turborepo project. We decided to use one global .env file for all the apps in the workspace in the root of the project.
Adding New Environment Variables
Follow these steps to add a new environment variable:
Create a new key value pair in the .env
file.
Add a new key value pair in the .env
file in the root directory of the project.
If it's a public environment variable, that's going to be used in the client-side code, make sure to prefix it with NEXT_PUBLIC_
.
Update the turbo.json file
Update the turbo.json
file in the root directory of the project to include the new environment variable in the globalEnv
object.
Access the environment variable
You can now access the environment variable using process.env.NEW_ENV_VARIABLE
.
Last updated on