---
title: "Manage scopes and deploy contexts for environment variables | Netlify Blog"
description: "Set different environment variable key pairs for distinct deploy contexts, like staging and production. Scope environment variables to be used only by specific features. Try the new environment variable experience today, available through Netlify Labs."
source: "https://www.netlify.com/blog/scopes-and-contextual-values-for-environment-variables/"
last_updated: "2026-07-10T20:16:07.000Z"
---
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 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.

The new Scopes and Deploy Contexts for Environment Variables experience is available in beta today [through Netlify Labs](https://app.netlify.com/user/labs).

![image](https://cdn.sanity.io/images/o0o2tn5x/production/c6e077fe08ca464515dcd799bdb849ae03384fee-2275x1356.jpg)

## Why scopes and deploy contexts matter for developer teams

Environment variables enable you to dynamically pull environmental config and sensitive values into your web application without committing secret data (such as private API tokens) to a repository or otherwise exposing it client-side. Wherever you reference the key, the value is swapped in and applied.

When you’re working with environment variables, you may need to:

-   Swap in a different value based on the deploy context, such as `staging` vs. `prod`
-   Escape the size limitations set by Lambda functions, especially if you’re using a large set of variables
-   Make certain data available only in certain scopes so you can avoid exposing variables where they’re not required

Previously, on Netlify, if you wanted to configure different values for environment variables based on deploy contexts, this required either a build plugin or [configuration in the .toml file](https://docs.netlify.com/configure-builds/file-based-configuration/#sample-netlify-toml-file). Configuring values in the .toml file doesn’t work for all environment variables, as they may be too sensitive to commit in code.

In order to unlock these more advanced use cases, we’re introducing the ability to set context-based values directly from the Netlify app UI.

If you’re on a team with a Pro plan and also have the new Scopes and Deploy Contexts for Environment Variables experience enabled, you’ll have the option to limit environment variables to specific scopes. This scoping functionality is available at both the site-level and for shared environment variables.

## How to get started

To get started, enable the “Scopes and Deploy Contexts for Environment Variables” beta in [Netlify Labs](https://app.netlify.com/user/labs). This will add an option on **Site settings > Environment variables** to migrate the site to the new environment variables experience.

Because the new experience is backed by a new, better-encrypted storage service, we want you to have control over which sites are migrated over during the beta. The first time a Collaborator or Owner migrates a site on your account to the new experience, any shared environment variables will also be copied over to the new experience.

[Learn more about migrating sites and rollbacks](https://docs.netlify.com/netlify-labs/experimental-features/environment-variables/#getting-started).

## Create more advanced environment variables

Once you have enabled the new experience for your site, you can add new environment variables under **Site settings > Environment variables**.

![image](https://cdn.sanity.io/images/o0o2tn5x/production/f3b5f25d0ce26f4bc568bf02354f0fda58e1f1b1-1737x1496.jpg)

Developers on Pro plans and above can choose to limit a variable to specific scopes, including:

-   `Builds`: includes site builds
-   `Functions`: includes Functions, Edge Functions, and On-Demand Builders
-   `Runtime`: includes forms and signed proxy redirects
-   `Post processing`: includes snippet injection

A variable scoped to builds only will not be available to use in any other scope.

![image](https://cdn.sanity.io/images/o0o2tn5x/production/b139d996e9dc2a8824954a2c75094bd7e7c3b2e7-1731x2132.jpg)

All developers can set one value for all deploy contexts or choose to set a different value for each of the following contexts:

-   `Production`: for the main site’s deployment
-   `Deploy Previews`: for previews we build for your pull/merge requests
-   `Branch deploys`: for all branch deploys. Soon you’ll be able to specify values for individual branch deploy contexts, such as `staging` or `docs` branches.
-   `Local development`: for local development using the Netlify CLI. Note that the updated CLI currently only supports accessing environment variables (using `env:get`, `env:list`, and `dev` commands) for migrated sites. The ability to modify these new variables from the CLI is coming soon.

The applied value will change based on the deploy context.

Once you’ve configured your environment variables to your liking, you can filter them by key or review individual values:

![image](https://cdn.sanity.io/images/o0o2tn5x/production/65d5e44da021819936eb47331100b3ac9d38896a-1910x676.png)

All environment variable changes are captured in the [team audit log](https://docs.netlify.com/accounts-and-billing/team-management/team-audit-log/) so you can keep track of any variables that are created, modified, or deleted.

As a reminder, you will need to rebuild your site in order for changes to be applied to environment variables.

## Known limitations during beta

While this new experience is in beta, there are some known limitations to note:

-   **Individual branch deploy contexts.** Currently, you can only set one value to be used across all branch deploy contexts. Soon you’ll be able to specify values for individual branch deploy contexts, such as staging or docs branches.
-   **Netlify CLI support.** [The latest Netlify CLI release](https://github.com/netlify/cli/releases) adds support for accessing environment variables, using the `netlify dev`, `netlify env:list`, and `netlify env:get` commands. The CLI can’t be used to create or update values for migrated sites at this time. We are actively working to add this functionality to the beta soon.
-   **Netlify API support.** [The Netlify API](https://open-api.netlify.com/#operation/listSitesForAccount) doesn’t support the new experience at this time but you can preview the upcoming beta API endpoints now.

If the Netlify CLI or API is a key part of your workflow, you may want to wait for updates coming to the beta in the weeks ahead.

## Try new environment variables settings today

Head over to [Netlify Labs](https://app.netlify.com/user/labs) to enable the beta, or get more details [in the docs](https://docs.netlify.com/netlify-labs/experimental-features/environment-variables/). 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](https://netlify.qualtrics.com/jfe/form/SV_cHlLLPAwunnWN4G). Thank you for trying out the new environment variables experience!

### Share

-   [X (fka Twitter)](https://twitter.com/intent/tweet?text=Manage scopes and contextual values for environment variables through the Netlify UI&url=https://www.netlify.com/blog/scopes-and-contextual-values-for-environment-variables/)
-   [LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.netlify.com%2Fblog%2Fscopes-and-contextual-values-for-environment-variables%2F)
-   [Facebook](https://www.facebook.com/sharer.php?u=https://www.netlify.com/blog/scopes-and-contextual-values-for-environment-variables/)
-   [Bluesky](https://bsky.app/intent/compose?text=Manage scopes and contextual values for environment variables through the Netlify UI+https://www.netlify.com/blog/scopes-and-contextual-values-for-environment-variables/)

* * *

### Tags

-   [deploy contexts](/blog/tags/deploy-contexts/)
-   [Netlify Labs](/blog/tags/netlify-labs/)

## Keep reading

![](/_astro/eb275ddb9290b947ba4c53ac30538c77b44edae9-720x405_1y2MXK.webp)

News & Announcements June 25, 2026

[

### Netlify Functions, designed for Agent Experience

](/blog/netlify-functions-designed-for-agent-experience)

-   ![Profile picture of Eduardo Bouças](/_astro/52958f21e8450baf6d8e60302341a984e220c0cd-512x512_13VDlu.webp)
    
    Eduardo Bouças
    

![](/_astro/d20f9f717bbdd511f73ee138be4114ff13f480f9-2400x1350_1fe4aq.webp)

News & Announcements June 24, 2026

[

### How we measure Netlify’s Agent Experience

](/blog/how-we-measure-netlify-agent-experience)

-   ![Profile picture of Sean Roberts](/_astro/bbf2243f8171dbddd80ab2103622106cef84d125-512x512_Z1d2LKE.webp)
    
    Sean Roberts
    

## Recent posts

News & Announcements June 25, 2026

[

### Netlify Functions, designed for Agent Experience

](/blog/netlify-functions-designed-for-agent-experience)

-   ![Profile picture of Eduardo Bouças](/_astro/52958f21e8450baf6d8e60302341a984e220c0cd-512x512_13VDlu.webp)
    
    Eduardo Bouças
    

News & Announcements June 24, 2026

[

### How we measure Netlify’s Agent Experience

](/blog/how-we-measure-netlify-agent-experience)

-   ![Profile picture of Sean Roberts](/_astro/bbf2243f8171dbddd80ab2103622106cef84d125-512x512_Z1d2LKE.webp)
    
    Sean Roberts
    

Guides & Tutorials May 15, 2026

[

### How to build a real-time AI chatbot in minutes with Netlify Agent Runners (no backend)

](/blog/how-to-build-a-real-time-ai-chatbot-in-minutes-with-netlify-agent-runners-no-backend)

-   ![Profile picture of Nahrin Jalal](/_astro/f0e7c8f227a03fe58340c99ef5439d5a896c0733-272x272_Z23kDpD.webp)
    
    Nahrin Jalal
    

![](/_astro/3f255b372fa958df35802666ee33b4609b2d71bd-1200x1586_1VtE2D.webp)

### How do the best dev and marketing teams work together?

[Access the report](https://www.netlify.com/reports/2024-leadership-trend-report/access/)