Skip to content

Package Managers

starlight-package-managers supports the following package managers:

Defaults

By default, starlight-package-managers will use npm, yarn and pnpm.

src/content/docs/example.mdx
import { PackageManagers } from 'starlight-package-managers'
<PackageManagers pkg="astro" />

The code above generates the following commands:

Terminal window
npm i astro

Customization

You can customize the package managers using the pkgManagers prop.

src/content/docs/example.mdx
import { PackageManagers } from 'starlight-package-managers'
<PackageManagers pkg="astro" pkgManagers={['npm', 'bun']} />

The code above generates the following commands:

Terminal window
npm i astro

Global Customization

Having to specify the pkgManagers prop every time can be tedious. To avoid this, you can create a custom Astro component wrapping starlight-package-managers:

src/components/AllPackageManagers.astro
---
import {
PackageManagers,
type PackageManagersProps,
} from 'starlight-package-managers'
type Props = PackageManagersProps
---
{/* Customize the package managers to use. */}
<PackageManagers
pkgManagers={['npm', 'yarn', 'pnpm', 'bun', 'ni']}
{...Astro.props}
/>

Now you can use the custom component instead of starlight-package-managers:

src/content/docs/example.mdx
import AllPackageManagers from '@/components/AllPackageManagers.astro'
<AllPackageManagers pkg="astro" />

The code above generates the following commands:

Terminal window
npm i astro