## CLI Usage

```bash terminal icon="terminal"
bun publish dist
```

### Publishing Options

<ParamField path="--access" type="string">
  Set the access level of the package being published, either `public` or `restricted`. Unscoped packages are always public; publishing an unscoped package with `--access restricted` is an error.

```sh terminal icon="terminal"
bun publish --access public
```

You can also set `--access` in the `publishConfig` field of your `package.json`.

```json package.json icon="file-json"
{
  "publishConfig": {
    "access": "restricted" // [!code ++]
  }
}
```

</ParamField>

<ParamField path="--tag" type="string" default="latest">
Set the tag of the package version being published. By default, the tag is `latest`. The initial version of a package is always given the `latest` tag in addition to the specified tag.

```sh terminal icon="terminal"
bun publish --tag alpha
```

You can also set `--tag` in the `publishConfig` field of your `package.json`.

```json package.json icon="file-json"
{
  "publishConfig": {
    "tag": "next" // [!code ++]
  }
}
```

</ParamField>

<ParamField path="--dry-run" type="boolean">
Simulate the publish process without publishing the package, to verify its contents first.

```sh
bun publish --dry-run
```

</ParamField>

<ParamField path="--tolerate-republish" type="boolean">
  `bun publish` exits with code 0 instead of 1 when the version being published already exists in the registry.
</ParamField>

<ParamField path="--gzip-level" type="string" default="9">
  Specify the level of gzip compression to use when packing the package. Only applies to `bun publish` without a tarball
  path argument. Values range from `0` to `9` (default is `9`).
</ParamField>

<ParamField path="--auth-type" type="string" default="web">

If you have 2FA enabled for your npm account, `bun publish` prompts you for a one-time password, either through a browser or the CLI. `--auth-type` tells the npm registry which method you prefer: `web` (the default) or `legacy`.

```sh terminal icon="terminal"
bun publish --auth-type legacy
...
This operation requires a one-time password.
Enter OTP: 123456
...
```

</ParamField>

<ParamField path="--otp" type="string">

Provide a one-time password directly to the CLI. A valid password skips the extra one-time password prompt before publishing.

```sh terminal icon="terminal"
bun publish --otp 123456
```

<Note>
  `bun publish` respects the `NPM_CONFIG_TOKEN` environment variable, so you can publish from GitHub Actions or other
  automated workflows.
</Note>

</ParamField>

### Registry Configuration

#### Custom Registry

<ParamField path="--registry" type="string">
  Use a specific registry by default, overriding .npmrc, bunfig.toml and environment variables. A registry configured
  for the package's scope (`@scope:registry=` in .npmrc or `[install.scopes]` in bunfig.toml) still takes precedence.
</ParamField>

```bash
bun publish --registry https://my-private-registry.com
```

#### SSL Certificates

<ParamField path="--ca" type="string">
  Provide Certificate Authority signing certificate
</ParamField>

<ParamField path="--cafile" type="string">
  Path to Certificate Authority certificate file
</ParamField>

<CodeGroup>
```bash Inline Certificate
bun publish --ca "-----BEGIN CERTIFICATE-----..."
```

```bash Certificate File
bun publish --cafile ./ca-cert.pem
```

</CodeGroup>

### General Options

#### Dependency Management

<ParamField path="-p, --production" type="boolean">
  Don't install devDependencies
</ParamField>

<ParamField path="--omit" type="string">
  Exclude dependency types: `dev`, `optional`, or `peer`
</ParamField>

<ParamField path="-f, --force" type="boolean">
  Always request the latest versions from the registry & reinstall all dependencies
</ParamField>

#### Script Control

<ParamField path="--ignore-scripts" type="boolean">
  Skip lifecycle scripts during packing and publishing
</ParamField>

<ParamField path="--trust" type="boolean">
  Add packages to trustedDependencies and run their scripts
</ParamField>

<Note>
  **Lifecycle Scripts** — When you publish a pre-built tarball, Bun does not run lifecycle scripts such as
  `prepublishOnly` and `prepack`; they only run when Bun packs the package itself.
</Note>

#### File Management

<ParamField path="--no-save" type="boolean">
  Don't update package.json or lockfile
</ParamField>

<ParamField path="--frozen-lockfile" type="boolean">
  Disallow changes to lockfile
</ParamField>

<ParamField path="--yarn" type="boolean">
  Generate yarn.lock file (yarn v1 compatible)
</ParamField>

#### Performance

<ParamField path="--backend" type="string">
  Platform optimizations: `clonefile` (default on macOS), `hardlink` (default on Linux and Windows), `symlink`, or
  `copyfile`
</ParamField>

<ParamField path="--network-concurrency" type="number" default="48">
  Maximum concurrent network requests
</ParamField>

<ParamField path="--concurrent-scripts" type="number">
  Maximum concurrent lifecycle scripts (default: 2x CPU cores)
</ParamField>

#### Output Control

<ParamField path="--silent" type="boolean">
  Suppress all output
</ParamField>

<ParamField path="--verbose" type="boolean">
  Show detailed logging
</ParamField>

<ParamField path="--no-progress" type="boolean">
  Hide progress bar
</ParamField>

<ParamField path="--no-summary" type="boolean">
  Don't print publish summary
</ParamField>
