# Override the default npm registry for bun install (/docs/guides/install/custom-registry)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 197 · updated: 2026-07-28 -->
Related: [Add a dependency](/docs/guides/install/add.md), [Add a development dependency](/docs/guides/install/add-dev.md), [Add an optional dependency](/docs/guides/install/add-optional.md), [Add a peer dependency](/docs/guides/install/add-peer.md), [Add a Git dependency](/docs/guides/install/add-git.md), [Add a tarball dependency](/docs/guides/install/add-tarball.md)

The default registry is `registry.npmjs.org`. Override it globally in `bunfig.toml`.

```toml bunfig.toml icon="settings"
[install]
# set default registry as a string
registry = "https://registry.npmjs.org"

# if needed, set a token
registry = { url = "https://registry.npmjs.org", token = "123456" }

# if needed, set a username/password
registry = "https://usertitle:password@registry.npmjs.org"
```

***

Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Environment variables](/runtime/environment-variables).

```toml bunfig.toml icon="settings"
[install]
registry = { url = "https://registry.npmjs.org", token = "$npm_token" }
```

***

See [`bun install`](/pm/cli/install).
