src/_navigation.ts. It reorders, hides, relabels, and re-parents built-in items, and it is the single source of truth for the sidebar’s shape.
When to use this vs. a
config export. New pages you add via drop-in routes place their own sidebar item through defineRouteConfig({ label, rank, nested }). _navigation.ts is for the items you didn’t create — the built-in ones. The two layer cleanly: custom routes place themselves; _navigation.ts reshapes the built-ins.What you’ll build
A vendor sidebar with Orders pinned to the top, Price Lists hidden, and Campaigns moved under Orders.Register the typed targets (once)
Nav item ids are typed and generated per panel. Register them once with a single ambient reference in your app’ssrc (already shipped by create-mercur-app):
apps/vendor/src/extension-targets.d.ts
id and nested autocomplete and an unknown id fails tsc.
Author the navigation file
Create src/_navigation.ts
The file is host-owned and underscore-prefixed. Default-export a
defineNavigationConfig with an items array of overrides:apps/vendor/src/_navigation.ts
Know the override fields
Each entry targets one built-in item by its stable
Both
id:| Field | Type | Effect |
|---|---|---|
id | NavItemId | Required. The built-in item to override (top-level or nested) |
rank | number | Order within its parent (lower first) |
hidden | boolean | Remove it from the sidebar |
label | string | Relabel (i18n key or literal) |
icon | ComponentType | Replace its icon |
nested | NavParentId | null | Re-parent under another top-level item; null promotes a nested item to top level |
id and nested are checked against the panel’s generated NavItemRegistry / NavParentRegistry.Common recipes
Verify
- The top-level order reflects your
rankvalues, withordersfirst. price-listsno longer appears in the sidebar.campaignsrenders as a child under Orders.- Set
id: "not-an-item"—bun run lint(tsc) fails againstNavItemRegistry. - Delete
_navigation.ts— the default sidebar returns.
FAQ
Can an installed block reorder the sidebar?
Can an installed block reorder the sidebar?
What ids can I target?
What ids can I target?
Any built-in item, top-level or nested, by its own id — e.g.
orders, products, categories, collections, campaigns, customer-groups. Let your editor autocomplete id: against NavItemId; the full set is generated into your panel’s extension-targets.d.ts.Does this work in the admin panel too?
Does this work in the admin panel too?
Yes — drop
src/_navigation.ts in the admin app and reference @mercurjs/admin/extension-targets. Each panel ships its own nav id set.How do I add a brand-new sidebar item?
How do I add a brand-new sidebar item?
Next steps
Add a custom panel page
Add a new screen with its own sidebar item.
Add a widget
Inject a component into a built-in page.