# How to use environment variables in Netlify functions

> Learn how to read environment variables in Netlify Functions through process.env, where to set them in the dashboard, and how Edge Functions use Deno.env.get.

Author: Flavio Copes | Published: 2020-05-25 | Updated: 2022-04-21 | Canonical: https://flaviocopes.com/netlify-functions-env-variables/

To use environment variables in your [Netlify Functions](https://flaviocopes.com/netlify-functions/), access the `process.env` variable:

```js
process.env.YOUR_VARIABLE
```

You can use object destructuring at the beginning of your JS file, to make the code nicer:

```js
const { YOUR_VARIABLE } = process.env;
```

so you can just use `YOUR_VARIABLE` in the rest of the program.

You set the variables through the [Netlify](https://flaviocopes.com/netlify/) administration interface (you can also add them in your repo, but I'd recommend using the Netlify UI so you have no secrets in your [Git](https://flaviocopes.com/git/) repository).

Note: this does not work on Netlify Edge Functions, just on Netlify "regular" Functions that run on AWS Lambda.

For Netlify Edge Functions, you need to use `Deno.env.get()`, like this:

```js
Deno.env.get('YOUR_VARIABLE')
```

Example:

```js
export default () => new Response(Deno.env.get('YOUR_VARIABLE'))
```
