blob: 7295a67265abcdcbebf1a81d851d4a2e996bdf64 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
---
name: Read environment variables
---
The current environment variables can be accessed via `process.env`.
```ts
process.env.API_TOKEN; // => "secret"
```
---
Bun also exposes these variables via `Bun.env`, which is a simple alias of `process.env`.
```ts
Bun.env.API_TOKEN; // => "secret"
```
---
To print all currently-set environment variables to the command line, run `bun run env`. This is useful for debugging.
```sh
$ bun run env
BAZ=stuff
FOOBAR=aaaaaa
<lots more lines>
```
---
See [Docs > Runtime > Environment variables](/docs/runtime/env) for more information on using environment variables with Bun.
|