[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.
index.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.env.production,.env.development,.env.test(depending on value ofNODE_ENV).env.local(not loaded whenNODE_ENV=test)
.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?
[
Set a time zone in Bun
Previous
](../timezone/index.md)[
Read environment variables
Next
](../read-env/index.md)