Package Manager

Display commands for multiple package managers with automatic syncing and switching.

Overview

The Package Manager components automatically generate code blocks showing the equivalent command across different package managers (npm, pnpm, bun, and yarn). This makes your documentation more accessible to users regardless of their preferred package manager.

Components

There are three main components for different command types:

  • ProsePmInstall - For installing packages
  • ProsePmRun - For running scripts
  • ProsePmX - For executing packages (npx, pnpm dlx, etc.)

All components support syncing, which allows users to switch between package managers once and have all command blocks update automatically.


ProsePmInstall

Use this component to show package installation commands across all package managers.

Basic Installation

Install a package

Install Multiple Packages

Dev Dependencies

Install packages as dev dependencies using the save-dev prop

Multiple Dev Dependencies

Install All Dependencies

Show the install command without a package name

Without Syncing

Disable syncing for standalone examples:

Custom Sync Key

Use a custom sync key to create separate sync groups

ProsePmRun

Use this component to show script execution commands.

Run Development Server

Run Build

Run Tests

Run Custom Scripts

Run with Arguments

Without Syncing

ProsePmX

Use this component for package execution commands (npx, pnpm dlx, bun x, yarn dlx).

Create New Project

Initialize Nuxt Project

Run Create Next App

Execute CLI Tools

TypeScript Init

Without Syncing

In-Stack Layout

All components support the in-stack prop for use within code groups or when you want a more compact display.

Installation in Stack

Run Script in Stack

Execute Command in Stack

Complete Setup Example

Here's a complete example showing a typical project setup workflow:

Getting Started
Follow these steps to set up your new project:

Step 1: Create Project

Step 2: Navigate to Directory

cd my-project

Step 3: Install Dependencies

Step 4: Install Additional Packages

Step 5: Install Dev Dependencies

Step 6: Run Development Server

Props Reference

ProsePmInstall Props

PropTypeDefaultDescription
namestring-Package name(s) to install. Omit for install command
save-devbooleanfalseInstall as dev dependency
in-stackbooleanfalseUse stack layout
syncstring"_pm"Sync group identifier
no-syncbooleanfalseDisable syncing

ProsePmRun Props

PropTypeDefaultDescription
scriptstringRequiredScript name to run
in-stackbooleanfalseUse stack layout
syncstring"_pm"Sync group identifier
no-syncbooleanfalseDisable syncing

ProsePmX Props

PropTypeDefaultDescription
commandstringRequiredCommand to execute
in-stackbooleanfalseUse stack layout
syncstring"_pm"Sync group identifier
no-syncbooleanfalseDisable syncing

Package Manager Differences

The components handle package manager-specific syntax automatically:

Install Command

Package ManagerInstallInstall (empty)Save Dev
npmnpm inpm install-D
pnpmpnpm ipnpm install-D
bunbun addbun install-d
yarnyarn addyarn install-D

Run Command

Package ManagerRun Script
npmnpm run
pnpmpnpm run
bunbun run
yarnyarn run

Execute Command

Package ManagerExecute
npmnpx
pnpmpnpm dlx
bunbun x
yarnyarn dlx

Syncing Behavior

By default, all package manager components within a page share the same sync group (_pm). When a user selects a package manager in one component, all other synced components update automatically.

Default Sync Group

These will sync together:

Custom Sync Groups

Create separate sync groups for different contexts:

Frontend Dependencies
Backend Dependencies

Disable Syncing

Use no-sync for standalone examples:

Real-World Examples

React Project Setup

Setting up a React + TypeScript Project

Create a new Vite project:

Install additional dependencies:

Install dev tools:

Start the development server:

Vue Project Setup

Setting up a Vue 3 Project

Create a new Vue project:

Install Vue Router and Pinia:

Install dev dependencies:

Run the dev server:

Nuxt Project Setup

Setting up a Nuxt 3 Project

Initialize a new Nuxt project:

Navigate to the project:

cd my-nuxt-app

Install dependencies:

Add UI library:

Start development:

Tips

Best Practices
  • Use syncing to provide a consistent experience across your documentation
  • Disable syncing for isolated examples or tutorials with different contexts
  • Use custom sync groups when you have multiple unrelated command sequences on the same page
  • Always show the installation command when introducing new dependencies
Note
The package manager selection is persisted in the user's browser, so their preference is remembered across pages and sessions.