@backstage/migrate-nav-item-to-page
Backstage 1.51.0 migration codemod that merges NavItemBlueprint navigation metadata into matching PageBlueprint extensions.
What it does
NavItemBlueprint was removed from @backstage/frontend-plugin-api in Backstage 1.51.0. Navigation items are now discovered from PageBlueprint extensions via their title and icon params.
For each NavItemBlueprint.make call, the codemod:
- Extracts
title,icon, androuteReffromparams - Finds the matching
PageBlueprint.makeorPageBlueprint.makeWithOverrideswith the same staticrouteRef - Adds
titleandiconto the page extension params (or theoriginalFactoryargument formakeWithOverrides) - Wraps MUI icon identifiers as
<Icon fontSize="inherit" />when the icon is not already JSX - Removes the nav item declaration and its entry from
extensionsarrays - Removes unused
NavItemBlueprintimports
Before / After
ts
Known limitations
- MUI to Remix icon migration is not performed — icons are wrapped as JSX elements only. Use
--param aiFixup=truefor heuristic MUI →@remixicon/reactconversion. - Dynamic
routeRefvalues (non-identifier expressions) are flagged withTODO(backstage-codemod)for manual migration. - Unpaired nav items (no matching
PageBlueprintwith the samerouteRef) are flagged withTODO(backstage-codemod)and left in place. - Ambiguous pairings (multiple pages sharing the same static
routeRef) are flagged withTODO(backstage-codemod). - Non-static icons (computed expressions, function calls) may need manual conversion to
IconElementJSX. - Namespace imports of
NavItemBlueprintare detected via usage patterns but not fully decomposed — use AI fixup for complex cases.
Optional: AI fixup step
Enable the AI-powered fixup step with --param aiFixup=true to address edge cases:
- Pair orphaned
NavItemBlueprintextensions with the correctPageBlueprint - Convert MUI icons to
@remixicon/reactwhere only used for navigation - Clean up
createFrontendModule/createFrontendPluginextension arrays - Resolve ambiguous pairings and dynamic
routeRefvalues
Installation
bash
Usage (from this repo)
bash
Development
From the repo root:
bash
Or from this package directory:
bash