# Bud.env usage

**URL:** https://discourse.roots.io/t/bud-env-usage/23607
**Category:** bud
**Tags:** sage10
**Created:** 2022-07-24T18:36:37Z
**Posts:** 3

## Post 1 by @falc0nline1 — 2022-07-24T18:36:38Z

From [docs](https://bud.js.org/docs/bud.env) everything looks easy.

I need to add to `.env` any key/value which starts from `PUBLIC_`. For example, `PUBLIC_TEST`.

than `yarn build` and variable should be able at `window`, but I can’t see any `PUBLIC_TEST`, `TEST`, `test` or `public_test`.

I even have tried to add `PUBLIC_TEST` as a global variable to wp-config.php but without a result.

Any thoughts?

---

## Post 2 by @kellymears — 2022-07-25T07:43:06Z

The docs are a bit out of date, sorry.

1. These values are not attached to `window`.
2. You don’t include `PUBLIC_` when referencing them in app code.

When I was testing, I also realized that these values should be run through json.stringify, otherwise you have to bake quotes into the env file.

Accomplished updating the docs and stringifying values in [✨Improve(patch): stringify env values by kellymears · Pull Request #1604 · roots/bud · GitHub](https://github.com/roots/bud/pull/1604).

For now, I tested with 6.3.3 and by setting:

```
// .env
PUBLIC_FOO="'test'"
```

```
// src/app.js 
console.log(FOO)
```

All seems to output as expected:

```
// dist/js/app.js
// ....
    813: () => {
      console.log('test')
    }
// ...
```

---

## Post 3 by @falc0nline1 — 2022-07-25T07:51:34Z

Thank you!  
Works for me!
