More tips for environment variables and Netlify CLI
Tags: netlify, cli, development
Published: 2021-12-11 01:24:21

---
title: More tips for environment variables and Netlify CLI
published: true
description: Netlify supports environment variables in your projects (including centrally managed team environment variables for use across all of your team's projects). Here's how you can manage them and use them in your local build environment.
tags: Netlify, CLI, Development
cover_image: https://www.netlify.com/img/blog/og-cli-env-vars.png/
canonical_url: https://www.netlify.app/blog/2021/12/10/more-tips-for-environment-variables-and-netlify-cli/
series: Netlify - a feature a day 2021
---

> Throughout December we'll be [highlighting a different Netlify feature each day](https://www.netlify.com/blog/2021/12/01/highlighting-a-different-netlify-feature-each-day-in-december/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars). It might just be the thing you need to unlock those creative juices, and [dust off that domain](https://www.netlify.com/blog/2021/12/01/dusty-domains-your-forgotten-domains-raise-money-for-charity/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars) you registered but never deployed! Keep an eye [on the blog](https://www.netlify.com/blog/2021/12/01/highlighting-a-different-netlify-feature-each-day-in-december/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars) and on [Twitter](https://twitter.com/netlify) for each feature!

As you'll see [in this post](https://www.netlify.com/blog/2021/12/09/use-access-share-environment-variables-on-netlify/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars), Netlify supports environment variables in your projects (including centrally managed team environment variables for use across all of your team's projects). A great feature of the [Netlify CLI](https://www.netlify.com/products/cli/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars) is that it lets you manage your project's environment variables without leaving your terminal, and can even make them available to your local development environment without the need for libraries or `.env` files.

Here are a few tips.

You'll first need to make sure that you have the [Netlify CLI](https://www.netlify.com/products/cli/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars) installed, and that you've linked your local project to a Netlify site.

```shell
# Install the Netlify CLI for use anywhere on your system
npm install -g netlify-cli
```

```shell
# Link your the current folder to an existing Netlify project
netlify link

# ...or create and link a new project in Netlify
netlify init
```

Now you can start managing the environment variables for the project.


#### Create or update an environment variable

```shell
# Set the value of an environment variable, creating it if needed
netlify env:set MY_ENV_VAR "some value"
```

#### Check the value of an environment variable

```shell
# Get the value of an environment variable
netlify env:get MY_ENV_VAR
```

#### Delete an environment variable

```shell
# Delete an environment variables
netlify env:unset MY_ENV_VAR
```

#### Listing all environment variables

```shell
# List all the environment variables available to this project
netlify env:list
```

#### Import environment variables from a file
```shell
# Import many environment variables from a local file
netlify env:import .env
```


#### Accessing environment variables during local development

Here's another place where [Netlify Dev](https://www.netlify.com/products/dev/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars) (bundled as part of the Netlify CLI) really shines. When you use Netlify Dev to run your project, it will automatically make your environment variable available to your code with `process.env.VARIABLE_NAME`. Just the same as when the code runs in [Netlify Build](https://www.netlify.com/products/build/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars) or your serverless [Netlify Functions](https://www.netlify.com/products/functions/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars).

```shell
# Detect, run, and your build,
# with all of your environment variables 
netlify dev
```


## More information

- [Docs: Environment variables](https://docs.netlify.com/configure-builds/environment-variables/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars#declare-variables)
- [Netlify CLI](https://www.netlify.com/products/cli/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars)
- [Netlify Dev — our entire platform, right on your laptop](https://www.netlify.com/blog/2019/04/09/netlify-dev-our-entire-platform-right-on-your-laptop/?utm_campaign=featdaily21&utm_source=devto&utm_medium=blog&utm_content=cli-env-vars)