Skip to content
✨ Publier v1 is live — a polished docs platform built for the open web.
On this page

VersionSwitcher

Docs version selector using browser-native <details>/<summary> — no JavaScript required.

The VersionSwitcher component from @publier/shell renders a version selector dropdown. It uses the browser-native <details>/<summary> element — no JavaScript bundle.

The default docs route places configured version selection in the header. Use product-aware navigation for independent product versions. Import VersionSwitcher directly for a custom layout; the Sidebar component also accepts a versions prop when a custom sidebar switcher is intentional.

Usage

---
import { VersionSwitcher } from '@publier/shell/components';
---
<VersionSwitcher
currentPath={Astro.url.pathname}
versions={[
{ label: 'v1 (latest)', path: '/docs', badge: 'stable', default: true },
{ label: 'v0.9 (legacy)', path: '/docs/v0.9', badge: 'legacy' },
]}
/>

In MDX:

import { VersionSwitcher } from '@publier/shell/components';
<VersionSwitcher
currentPath="/docs/getting-started"
versions={[
{ label: 'v1 (latest)', path: '/docs', badge: 'stable' },
{ label: 'v0.9 (legacy)', path: '/docs/v0.9', badge: 'legacy' },
]}
/>

Props

VersionSwitcher

PropTypeDefaultDescription
versionsDocVersion[]requiredOrdered list of doc versions.
currentPathstringundefinedCurrent page pathname — used to detect the active version via longest-prefix match.

DocVersion

PropTypeDefaultDescription
labelstringrequiredDisplay label (e.g. "v1 (latest)").
pathstringrequiredRoot path for this version (e.g. "/docs").
badge'stable' | 'beta' | 'deprecated' | 'legacy'undefinedOptional badge shown next to the label in the dropdown.
defaultbooleanfalseMark as the default when no path match is found.
status'current' | 'supported' | 'frozen' | 'preview'undefinedThe version’s lifecycle status. This component uses it only to pick the active version (see Behaviour).

Behaviour

  • Implemented as a native <details>/<summary> — opens and closes without JavaScript.
  • Active version is found by the longest path-prefix that matches currentPath: /docs/getting-started matches /docs before /.
  • When no path match is found, the version at / is used; if none, the version with default: true, then the one with status: 'current', then the first version.
  • Each option links to its version’s path. The archived banner, the Archived group in the menu and same-page switching come from versions configured in publier.config.yaml and rendered by the default docs route (version lifecycle); this standalone component renders none of them.
  • No client directive needed — this component renders pure HTML.