Note: This documentation is for version 1 of the ZEIT Now platform. For the latest features, please see the version 2 documentation. If you have yet to upgrade, see the upgrade guide.

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 ZEIT Now is easy.

Via CLI

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",
    "MY_API_TOKEN": "XXXXX"
  }
}

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 ZEIT Now Secrets.