Skip to content
Bun
Bun
Processes & System

Read environment variables

Access the current environment variables with process.env.

index.ts
process.env.API_TOKEN; // => "secret"

Bun also exposes these variables as Bun.env, an alias of process.env.

index.ts
Bun.env.API_TOKEN; // => "secret"

To print all currently-set environment variables, run bun --print process.env.

terminal
bun --print process.env
{
  BAZ: "stuff",
  FOOBAR: "aaaaaa",
  <lots more lines>
}

See Environment variables.

Was this page helpful?Suggest editsRaise issue