Environment Variables

Almost every app needs to get configurations at runtime. These configurations could be anything, including:
  • Database connection details
  • Third-party API keys
  • Different customization parameters
The best way to expose these configurations is to do so with environment variables, which is a universally available method that works across various programming languages, operating systems and hosting providers.
Exposing environment variables with now is easy.


You can expose environment variables with the -e flag.
now -e MONGO_URL="user:password@mydb.com" -e MY_API_TOKEN="XXXXX"
You can then access them inside your app.
If your app is a Node.js app, here's how you can do that:
const { MONGO_URL, MY_API_TOKEN } = process.env

Via “now.json”

You can also expose these environment variables with now.json. For that, create a file named now.json inside your app root and add environment variables like this:
  "env": {
    "MONGO_URL": "user:password@mydb.com",
After that, now will use above environment variables when you deploy your app.
It's not a good idea to commit the now.json file to Git if it contains secret information. For that, consider using now Secrets.