package.json and reference them throughout your project.
Overview
Instead of each workspace package specifying its own versions, you:- Define version catalogs in the root
package.json - Reference those versions with the
catalog:protocol - Update every package at once by changing the version in one place
How to Use Catalogs
Directory Structure Example
Consider a monorepo with the following structure:1. Define Catalogs in Root package.json
In your root-levelpackage.json, add a catalog or catalogs field within the workspaces object:
package.json
catalog and catalogs also work at the top level of package.json.
2. Reference Catalog Versions in Workspace Packages
In your workspace packages, use thecatalog: protocol to reference versions:
packages/app/package.json
packages/ui/package.json
catalog: references work in dependencies, devDependencies, optionalDependencies, peerDependencies, and as the value of a root overrides rule. A catalog reference behaves exactly as if the catalog’s range were written inline.
3. Run Bun Install
Runbun install to install all dependencies according to the catalog versions.
Catalog vs Catalogs
Bun supports two ways to define catalogs:-
catalog(singular): A single default catalog for commonly used dependenciesReference withpackage.jsoncatalog::packages/app/package.json -
catalogs(plural): Multiple named catalogs for grouping dependenciesReference withpackage.jsoncatalog:<name>:packages/app/package.json
Benefits of Using Catalogs
- Consistency: All packages use the same version of critical dependencies
- Maintenance: Update a dependency version in one place instead of across multiple
package.jsonfiles - Clarity: Makes it obvious which dependencies are standardized across your monorepo
- Simplicity: No extra version resolution strategies or external tools
Real-World Example
A larger example, for a React application: Root package.jsonpackage.json
packages/app/package.json
packages/ui/package.json
packages/utils/package.json
Updating Versions
To update versions across all packages, change the version in the root package.json:package.json
bun install to update all packages.
Adding to the catalog with bun add
bun add --catalog (or --catalog=<name>) adds the entry to the root catalog and writes "catalog:" to the current package. An existing catalog entry is reused unless you pass an explicit version. See bun add --catalog.
terminal
bun add react (no version) writes "catalog:" when the default catalog already lists react. Pass a version to write a concrete range instead.
Lockfile Integration
Bun’s lockfile tracks catalog versions, so installs are consistent across environments. The lockfile includes:- The catalog definitions from your package.json
- The resolution of each cataloged dependency
bun.lock(excerpt)
Limitations and Edge Cases
- Catalog references must match a dependency defined in either
catalogor one of the namedcatalogs - Empty strings and whitespace in catalog names are ignored (treated as default catalog)
catalog:defaultis the same ascatalog:. The default catalog can be defined as eithercatalogorcatalogs.default, but a package listed in both is an error- Invalid dependency versions in catalogs fail to resolve during
bun install catalog:only works in the root and workspacepackage.jsonfiles. Inside a published package it fails to resolve — publish withbun publishorbun pm pack, which replace it with the real range (see Publishing)
Publishing
When you runbun publish or bun pm pack, Bun replaces catalog: references
in your package.json with the resolved version numbers. The published package
includes regular semver strings and no longer depends on your catalog
definitions.