bun-publish
TLDR
Publish the current package to the npm registry
Publish a package from a specific directory
Publish a scoped package with specific access level
Publish a package to a custom registry
Run a dry run to see what would be published without uploading
Publish a package with a specific distribution tag
Publish with a one-time password for 2FA-enabled accounts
Publish using a specific authentication type
SYNOPSIS
bun publish [<dir>] [--registry <url>] [--otp <code>] [--dry-run] [--tag <tag>] [--access <public|restricted>]
PARAMETERS
--registry <url>
npm registry URL (default: https://registry.npmjs.org)
--otp <code>
One-time password for 2FA on scoped packages
--dry-run
Simulate publish without uploading
--tag <tag>
Dist-tag like latest, next (default: latest)
--access <public|restricted>
Package visibility (default: public)
<dir>
Directory to publish from (default: current)
DESCRIPTION
The bun publish command (invoked as bun publish) is part of Bun's built-in package manager, designed for speed and simplicity. It uploads your JavaScript/TypeScript package to the npm registry, similar to npm publish or yarn publish, but leverages Bun's rapid performance for bundling, transpiling, and tarball creation.
It automatically handles package.json validation, generates a gzipped tarball, and pushes it to the specified registry. Bun publish is up to 20x faster than npm due to its Zig-based runtime and native optimizations. Use it in monorepos or for quick iterations.
Prerequisites: Authenticate with bun login or set NPM_TOKEN. Supports scoped packages with OTP for 2FA. Ideal for modern JS workflows with ESM, TypeScript, and JSX out-of-the-box.
CAVEATS
Requires bun login or NPM_TOKEN env var. Does not support prepublish scripts by default. Scoped private packages need --access restricted. Tarball size optimized but verify with --dry-run.
AUTHENTICATION
Run bun login or export NPM_TOKEN=your_token. For scoped: bun publish --otp $(bunx @jsdevtools/otp-auth).
EXAMPLES
bun publish # Current dir to latest
bun publish ./my-pkg --tag beta --registry https://registry.npmjs.org
HISTORY
Introduced in Bun 0.1.0 (Sept 2022) by Jarred Sumner. Evolved with Bun 1.0 (2023) for full npm compatibility. Widely adopted for its speed in CI/CD pipelines.


