Scopes and Deploy Contexts for Environment Variables

We’re excited to share that developers can now limit environment variables to specific scopes or change environment variables based on deploy context through the Netlify UI! With this beta release, developers no longer need to use a build plugin or commit any secrets to the Netlify .toml file in order to change the variable value based on deploy context. Scopes enable you to configure where sensitive values can be used, and can help avoid Lambda function limits on environment variables.

New environment variables page with variables that have different values in different contexts, and are on different scopes

Teams on Pro plans and above can limit an environment variable so that it is only available to particular scopes, such as builds, functions, runtime, or post-processing. All developers can change the variable value based on deploy context: production, Deploy Previews, branch deploys (all), and local CLI development. Branch-deploy-specific values are coming soon.

New environment variable creation form with individual scopes: builds, functions, runtime, and post-processing

The new Scopes and Deploy Contexts for Environment Variables experience is available in beta today through Netlify Labs. Once the beta is enabled in Labs, you’ll be able to enable the new experience on a per-site basis in Site Settings. The new experience is backed by a new service with enhanced encryption, so we want you to have control over which sites are migrated over during this early release.

Check out the docs to learn more about:

  • How to migrate your sites and shared environment variables to the new experience
  • How to use the new scopes and contexts functionality
  • Known issues and limitations while we work to complete CLI and API support

We have more planned for environment variables in this beta release and in the future, so we’d love to get your thoughts on all things variables. Thank you for trying out the new environment variables experience!