Skip to main content
Access the current environment variables with process.env.
https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35bindex.ts
process.env.API_TOKEN; // => "secret"

Bun also exposes these variables as Bun.env, an alias of process.env.
https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35bindex.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.