# Configure scoped private packages in Bun

Used: bun@1.1.18

Create a `bunfig.toml` file and put the following code:

```txt {% path="bunfig.toml" %}
[install.scopes]
"@scope" = { token = "REGISTRY_TOKEN", url = "REGISTRY_URL" }
```

Replace `@scope` with your package scope, e.g. `@company-name`.

Replace `REGISTRY_TOKEN` with an actual token your registry provides you, you can use `$TOKEN` (with the leading `$`) to reference a environment variable, useful to avoid hard coding it specially on public repos and it can be set in your deployment platform too.

Then replace `REGISTRY_URL` with the URL of the registry that holds your package, e.g. `https://npm.pkg.github.com` can be used to point to GitHub Package Registry which can be used for private package within an organizations.

And that's it, now you can do `bun add @scope/package` and it should work.

---

If you're on v1.1.18 on Bun, you can also just use `.npmrc` file.

```txt {% path=".npmrc" %}
@scope:registry=REGISTRY_URL
//REGISTRY_URL/:_authToken=REGISTRY_TOKEN
```

Same as with `bunfig.toml`, you can use `$TOKEN` as replacement of `REGISTRY_TOKEN` to use an environment variable.