skills/bun-guides-runtime-set-env/SKILL.md
Set environment variables
npx skillsauth add jarle/bun-skills Bun Set environment variablesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The current environment variables can be accessed via process.env or Bun.env.
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 of NODE_ENV).env.local (not loaded when NODE_ENV=test)FOO=hello
BAR=world
Variables can also be set via the command line.
<CodeGroup> ```sh Linux/macOS icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}} FOO=helloworld bun run dev ```# Using CMD
set FOO=helloworld && bun run dev
# Using PowerShell
$env:FOO="helloworld"; bun run dev
</CodeGroup>
See Docs > Runtime > Environment variables for more information on using environment variables with Bun.
development
Using TypeScript with Bun, including type definitions and compiler options
development
Learn how to write tests using Bun's Jest-compatible API with support for async tests, timeouts, and various test modifiers
testing
Learn how to use snapshot testing in Bun to save and compare output between test runs
testing
Learn about Bun test's runtime integration, environment variables, timeouts, and error handling