---
title: "Easy Access Environment Variables"
description: "Learn how to store sensitive information like secret keys while still giving your team easy access with Netlify environment variables."
source: "https://www.netlify.com/blog/2021/07/05/easy-access-environment-variables/"
last_updated: "2026-07-10T20:16:09.000Z"
---
When it comes to handling sensitive information like private keys, there are two scenarios that always come to mind:

-   😱 adding the important, private values to code that then gets pushed up to GitHub for the world to see
-   😓 having to wait for a teammate to share the keys before anyone can contribute to a project

I have definitely gone through both of these scenarios and possibly, you have too. When I learned about how [Netlify stores project environment variables](https://ntl.fyi/3wOorom) I realized it was the answer to both of these yucky situations.

## Setting Environment Variables

There are three different ways we can set these variables for Netlify projects. My go-to is via the project dashboard in ‘Site settings > Build & deploy > Environment > Environment variables’. These variables can be edited and removed with a click of a button.

![project dashboard list of environment variable](/v3/img/blog/screen-shot-2021-06-22-at-1.42.49-pm.jpg "project dashboard list of environment variable")

The same approach can be made in team settings to make environment variables available to all of your projects. This is super handy for information that needs to be shared across multiple projects but they can also be overwritten at the site level. This can be set in the team settings, ‘Team settings > Sites > Global site settings > Shared environment variables’.

![team settings dashboard](/v3/img/blog/screen-shot-2021-06-22-at-10.31.49-pm.jpg "team settings dashboard")

Thirdly, if the variables we want to add aren’t private infrormation, we can set environment variables in the [Netlify configurations file,`netlify.toml`](https://ntl.fyi/3xI8GiF)(this file gets committed so no privacy here!). The variables can be set to different [deploy contexts](https://ntl.fyi/3gUYY63) and this file will override anything set in the UI. Here’s an example of what that might look like:

`/netlify.toml`

```
[context.production]  publish = "dist/my-project"  command = "ng build --prod"  environment = { NOT_PRIVATE_STUFFS = "totally not top secret", NODE_VERSION = "14.15.3", API_KEY = "abc1234teeheehee" }
[context.staging] # “staging” is a branch name  command = "echo 'staging'"  base = "staging"  environment = { SOME_KEY = "t0te5Important5tuff" }
```

## Using Environment Variables

Inside of your code, these variables can be referenced by putting `process.env.` in front of the name of the environment variable. So, if the key is `MY_SECRET_SAUCE`, the code we call it with will look like this:

```
const topSecretRecipe = process.env.MY_SECRET_SAUCE;
timeForDinner(topSecretRecipe);
```

## Such Benefits

Having this information stored on the project dashboard means that you can keep it out of your code completely. It’s great when we remember to hold keys in `.env` files but not so great when we forget to add that file to the `.gitignore` list. That whole “remembering” thing is very hard and, personally, I prefer to avoid it completely. Storing environment variables this way makes it so computers do all our remembering, the way it should be.

Being your team can access the project’s dashboard they are able to add and edit variables. When coding locally you can use [`ntl dev`](https://www.netlify.com/platform/core/cli/?utm_campaign=devex-tzm&utm_source=blog&utm_medium=blog&utm_content=env-vars) to serve up the project and the environment variables are automatically added from Netlify. Better still, even when team members don’t have access they can look at [deploy previews](https://ntl.fyi/3xOpe91) that take advantage of the correct environment variables.

## Any Questions?

Interested? Want to learn more? Check out [the documentation on build environment variables](https://ntl.fyi/3wOorom) or our [place to get answers, the Netlify Support Forums](https://answers.netlify.com/). There’s a lot more you can do with environment variables so check out the docs to learn about:

-   [the sensitive variable policy](https://ntl.fyi/2SOkgdC)
-   [setting custom values for certain reserved environment variables](https://docs.netlify.com/configure-builds/environment-variables/?utm_campaign=devex-tzm&utm_source=blog&utm_medium=blog&utm_content=env-vars#netlify-configuration-variables)
-   [and pre-defined variables for meta-data like build, git, deploy URLs, build hook meta-data, and payloads](https://docs.netlify.com/configure-builds/environment-variables/?utm_campaign=devex-tzm&utm_source=blog&utm_medium=blog&utm_content=env-vars#read-only-variables)

That’s right, your environment variable fun has just begun. Happy coding 👩🏻‍💻!

### Share

-   [X (fka Twitter)](https://twitter.com/intent/tweet?text=Easy Access Environment Variables&url=https://www.netlify.com/blog/2021/07/05/easy-access-environment-variables/)
-   [LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.netlify.com%2Fblog%2F2021%2F07%2F05%2Feasy-access-environment-variables%2F)
-   [Facebook](https://www.facebook.com/sharer.php?u=https://www.netlify.com/blog/2021/07/05/easy-access-environment-variables/)
-   [Bluesky](https://bsky.app/intent/compose?text=Easy Access Environment Variables+https://www.netlify.com/blog/2021/07/05/easy-access-environment-variables/)

* * *

### Tags

-   [Build](/blog/tags/Build/)

## Keep reading

![](/_astro/bbe3cfe0b5d5228f5d0a66e26ce057de315c7712-1200x675_ZQfk21.webp)

Tools & Services December 3, 2025

[

### Vibe coding to production with Kiro powers

](/blog/vibe-coding-production-kiro-powers)

-   ![Profile picture of Gehrig Kunz](/_astro/b4e9f58d914d1334ea70d53ea55a1f26b26f1445-512x512_17SwOI.webp)
    
    Gehrig Kunz
    

![](/_astro/b596a7453ede5fe6739bd12506636fe522828198-2400x1351_1ANtEG.webp)

Tools & Services February 21, 2025

[

### Secure local development with Codezero for Netlify

](/blog/secure-local-development-codezero)

-   Kathleen Randall
    

## 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/)