rembrembdocs

Skip to main content

Bun home pagelight logodark logo

[Runtime

](../../../index.md)[Package Manager

](../../../pm/cli/install/index.md)[Bundler

](../../../bundler/index.md)[Test Runner

](../../../test/index.md)[Guides

](../../index.md)[Reference

](https://bun.com/reference)[Blog

](https://bun.com/blog)[Feedback

](../../../feedback/index.md)

The current environment variables can be accessed via process.env or Bun.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"
process.env.API_TOKEN; // => "secret"

Set these variables in a .env file. Bun reads the following files automatically (listed in order of increasing precedence).

.env

FOO=hello
BAR=world

Variables can also be set via the command line.

FOO=helloworld bun run dev

See Docs > Runtime > Environment variables for more information on using environment variables with Bun.

Was this page helpful?

Suggest editsRaise issue

[

Set a time zone in Bun

Previous

](../timezone/index.md)[

Read environment variables

Next

](../read-env/index.md)