Skip to content

ref(plugins): prefer Backstage routing and lazy adapters - #35692

Draft
schultzp2020 wants to merge 12 commits into
backstage:masterfrom
schultzp2020:feature/33603-scoped-routing-migration
Draft

schultzp2020 wants to merge 12 commits into
backstage:masterfrom
schultzp2020:feature/33603-scoped-routing-migration

Conversation

@schultzp2020

@schultzp2020 schultzp2020 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Hey, I just made a Pull Request!

Adopts the scoped routing introduced in #34830, following RFC #33603. Rebased onto the current head of the routing PR, so the API surface is the rewritten one: useAppHref, RouterLink, contextual useNavigation, and getSnapshot()-based app history reads.

This diagram shows how framework navigation and the remaining local routers share one history.

flowchart TD
  History["AppHistoryApi<br/>provided by #34830"] --> Scope["Matched plugin page or sub-page"]
  Scope --> Routerless["Backstage links and hooks<br/>no page adapter"]
  Scope --> Lazy["Lazy page component"]
  Lazy --> V6["React Router v6 adapter<br/>only for local routes and outlets"]
  V6 --> Local["Entity tabs, reader paths,<br/>consent and scaffolder routes"]
  Links["Shared links, query state<br/>and cross-plugin navigation"] --> History
  History --> Demo["Lazy examples<br/>v6, v7, TanStack and implicit compatibility"]
Loading

What changed

  • Removed page adapters and their dependencies from api-docs, catalog-graph, catalog-import, catalog-unprocessed-entities, home, notifications, search, and user-settings. Catalog and TechDocs index pages, plus scaffolder actions and templating-extension pages, also render without adapters.
  • Auth, catalog entity pages, the TechDocs reader, and scaffolder templates/tasks/editor keep v6 adapters around their local routes. The adapter renders inside the lazily loaded page component; blueprint loaders only import and render the component.
  • Shared links and navigation prefer Backstage APIs with React Router fallback for the old frontend system: Link binds through contextual useNavigation when app history is registered and falls back to React Router otherwise; EntityRefLink resolves through useAppHref. Link targets retain deployment basenames, native modified clicks, downloads, navigation state, and replacement behavior.
  • App chrome components (ErrorPage, Sidebar) intentionally stay on React Router for now, following the routing PR's own decision; routerless chrome is a later step on top of both PRs.
  • Catalog filters, search edits and history state, log selections, action fragments, and TechDocs anchors publish through app history, reading locations via getSnapshot(). Search Back/Forward restores cleared parameters as well as populated ones.
  • Notification links such as catalog/example resolve from the app root; search modal submissions encode terms containing URLs.
  • Removed the unused App Visualizer router, four unused react-router-dom peers, and the v6 adapter's redundant react-router peer. Comments, tests, examples, and changesets reflect the current routing behavior.

Compatibility and migration

This migration can land separately from the feature. #34830 retains implicit v6 compatibility for existing new frontend pages and warns in development when an extension consumes it. Plugins need no immediate migration. Pages using only Backstage routing, or no routing at all, need no adapter declaration and receive no migration warning.

Legacy frontend exports and their outlet customization remain supported. The shared helpers use React Router fallback when app history is absent. Converted legacy routes keep their compatibility adapters.

This PR targets feature/33603-scoped-routing-base so the diff contains only migration and example-app changes. Rebase and retarget it to master after #34830 merges.

Demo and remaining limits

The example app exercises mixed-adapter tabs and nested routes at /nfs-routing-demo, /nfs-routing-demo-v7, and /nfs-routing-demo-tanstack. Adapters load with their React components. One tab deliberately uses implicit compatibility; other pages demonstrate framework routing without adapters. Panels show resolved URLs and link destinations, with route-ref links built from useRouteRef plus RouterLink.

Regression coverage includes migrated plugin navigation, routerless links, legacy tabs, query edits and history traversal, action fragments, and the mixed-router demos. On the rebased head: 914 suites / 7448 tests pass across all touched workspaces, with repo-wide type checking and API report generation clean. Backend database suites that require a container runtime are excluded locally.

React Router remains required for supported legacy routing and the local route trees listed above. Navigation blockers and custom-history restoration retain the limits described in #34830.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@github-actions github-actions Bot added area:documentation Improvements or additions to documentation area:catalog Related to the Catalog Project Area area:techdocs Related to the TechDocs Project Area area:scaffolder Everything and all things related to the scaffolder project area area:home area:search labels Sep 15, 2026
@backstage-goalie backstage-goalie Bot added size:huge Huge pull requests receive a lower priority for reviews. waiting-for:review The PR needs a review and will be visible in the review queue unless already assigned an owner. labels Sep 15, 2026
@schultzp2020
schultzp2020 force-pushed the feature/33603-scoped-routing-migration branch from 12107c9 to 7df9440 Compare September 15, 2026 15:52
@schultzp2020 schultzp2020 changed the title ref(plugins): adopt scoped page routers and app navigation ref(plugins): prefer Backstage routing and lazy adapters Sep 15, 2026
@schultzp2020
schultzp2020 force-pushed the feature/33603-scoped-routing-migration branch 3 times, most recently from a5876ab to c32e4f2 Compare September 15, 2026 19:35
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!

@github-actions github-actions Bot added the stale label Oct 15, 2026
@github-actions github-actions Bot closed this Oct 29, 2026
@schultzp2020 schultzp2020 reopened this Nov 3, 2026
@github-actions github-actions Bot removed the stale label Nov 3, 2026
@schultzp2020
schultzp2020 force-pushed the feature/33603-scoped-routing-migration branch from c32e4f2 to dd01b04 Compare November 9, 2026 21:34
@schultzp2020
schultzp2020 force-pushed the feature/33603-scoped-routing-base branch from c3f8688 to d7b3104 Compare November 9, 2026 21:34
@schultzp2020
schultzp2020 force-pushed the feature/33603-scoped-routing-migration branch from dd01b04 to 2939d70 Compare November 9, 2026 21:39
schultzp2020 and others added 8 commits November 11, 2026 11:15
Reorganize the existing scoped routing implementation for RFC backstage#33603.

Co-authored-by: Cursor <[email protected]>
Signed-off-by: Paul Schultz <[email protected]>
Reorganize the existing scoped routing implementation for RFC backstage#33603.

Co-authored-by: Cursor <[email protected]>
Signed-off-by: Paul Schultz <[email protected]>
Adapt the plugin migration to the rewritten scoped routing base:

- core-components Link binds through the contextual useNavigation hook
  with an app-history presence check, replacing the removed
  useAppRouting/useOptionalAppHistory machinery, and keeps the
  React Router fallback for the old frontend system
- useAppHref replaces the removed useHref in EntityRefLink, demo
  pages, and readouts; RouteLink usages become useRouteRef plus
  RouterLink; the relative framework link resolves through the
  nearest navigation provider
- app history location reads go through getSnapshot().location
  (catalog filters, search state, techdocs content data, tests)
- Link and demo tests mount adapters through NavigationProvider
  instead of the removed PageMountProvider, and the TanStack demo
  readout derives its scoped remainder from the mount base path
- shared-component suites keep the base's streamEntities-based
  EntityListProvider tests and re-add the app-history filter test
- chrome components stay on React Router per the base PR's decision
  (bfecdcc), so ErrorPage, Sidebar, and appRouting conversions
  are dropped

Signed-off-by: Paul Schultz <[email protected]>
The scoped routing PR renamed the adapter packages when it landed:
@backstage/plugin-app-react-router-v6/v7 and
@backstage/plugin-app-tanstack-router are now
@backstage/frontend-adapter-react-router-v6/v7 and
@backstage/frontend-adapter-tanstack-router. Update imports,
dependencies, and docs accordingly, and regenerate the lockfile.

Signed-off-by: Paul Schultz <[email protected]>
@schultzp2020
schultzp2020 force-pushed the feature/33603-scoped-routing-migration branch from 2939d70 to bc8b8d4 Compare November 11, 2026 18:27
@schultzp2020
schultzp2020 changed the base branch from feature/33603-scoped-routing-base to master November 11, 2026 18:27
@backstage-goalie

backstage-goalie Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @backstage/core-compat-api
  • @backstage/frontend-adapter-react-router-v7
  • @backstage/frontend-adapter-tanstack-router
  • @backstage/frontend-app-api
  • @backstage/frontend-plugin-api
  • @backstage/frontend-test-utils
  • @backstage/ui
  • @backstage/plugin-app

See CONTRIBUTING.md for more information about how to add changesets.

Unexpected Changesets

The following changeset(s) reference packages that have not been changed in this PR:

  • /home/runner/work/backstage/backstage/.changeset/routerless-plugin-pages.md: @backstage/plugin-catalog-import, @backstage/plugin-catalog-unprocessed-entities, @backstage/plugin-user-settings

Note that only changes that affect the published package require changesets, for example changes to tests and storybook stories do not require changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
example-app packages/app none v0.0.41-next.2
@backstage/core-compat-api packages/core-compat-api none v0.6.0-next.2
@backstage/core-components packages/core-components patch v0.18.16-next.1
@backstage/core-plugin-api packages/core-plugin-api patch v1.12.12-next.2
@backstage/frontend-adapter-react-router-v6 packages/frontend-adapter-react-router-v6 patch v0.2.0-next.0
@backstage/frontend-adapter-react-router-v7 packages/frontend-adapter-react-router-v7 none v0.2.0-next.0
@backstage/frontend-adapter-tanstack-router packages/frontend-adapter-tanstack-router none v0.2.0-next.0
@backstage/frontend-app-api packages/frontend-app-api none v0.17.0-next.2
@internal/frontend packages/frontend-internal none v0.0.26-next.2
@backstage/frontend-plugin-api packages/frontend-plugin-api none v0.19.0-next.2
@backstage/frontend-test-utils packages/frontend-test-utils none v0.7.0-next.2
@backstage/theme packages/theme patch v0.7.3
@backstage/ui packages/ui none v0.20.0-next.0
@backstage/version-bridge packages/version-bridge patch v1.0.12
@backstage/plugin-api-docs-module-protoc-gen-doc plugins/api-docs-module-protoc-gen-doc patch v0.1.11
@backstage/plugin-api-docs plugins/api-docs patch v0.14.7-next.2
@backstage/plugin-app-visualizer plugins/app-visualizer patch v0.2.10-next.2
@backstage/plugin-app plugins/app none v0.6.0-next.2
@backstage/plugin-auth plugins/auth patch v0.1.14-next.2
@backstage/plugin-catalog-graph plugins/catalog-graph patch v0.6.10-next.2
@backstage/plugin-catalog-react plugins/catalog-react patch v4.0.0-next.2
@backstage/plugin-catalog plugins/catalog patch v2.0.11-next.2
@backstage/plugin-home plugins/home patch v0.9.12-next.2
@backstage/plugin-notifications plugins/notifications patch v0.6.2-next.2
@backstage/plugin-scaffolder-node-test-utils plugins/scaffolder-node-test-utils patch v0.3.17-next.1
@backstage/plugin-scaffolder plugins/scaffolder patch v1.41.0-next.2
@backstage/plugin-search plugins/search patch v1.7.10-next.2
@backstage/plugin-techdocs plugins/techdocs patch v1.19.1-next.2

CodeQL flags the parameter segment expression in compilePath as a
potential polynomial-time regular expression on inputs like long runs
of dashes. Replace it with a linear scan: the name is the longest run
of word characters after the colon, an optional question mark follows,
and the remainder is a literal suffix. Segment semantics are
unchanged, covered by a no-backtracking regression test on adversarial
input.

Signed-off-by: Paul Schultz <[email protected]>
@schultzp2020
schultzp2020 force-pushed the feature/33603-scoped-routing-migration branch from bc8b8d4 to ee9cf5a Compare November 11, 2026 18:53
The featured-templates home widget renders on the home page grid,
outside any page adapter, so React Router's useNavigate only worked
through implicit compatibility and warned in development. Use
useAppNavigate, which prefers the app history and falls back to React
Router in the old frontend system.

Signed-off-by: Paul Schultz <[email protected]>
React 18 is required, so useSyncExternalStore comes from React
itself. Import the native hook in the app history location and
router, route ref resolution, and the UI breakpoint hook, and remove
the now-unused use-sync-external-store and @types/use-sync-external-
store dependencies, including the re-declarations the inline-package
rule required. Drop the React 17 fallback mock from the app history
location test; it exercises the native hook like every other suite.

Signed-off-by: Paul Schultz <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

yarn.lock changes

Click to toggle table visibility
Name Status Previous Current
@types/use-sync-external-store DOWNGRADED 1.7.0 0.0.6

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:catalog Related to the Catalog Project Area area:documentation Improvements or additions to documentation area:home area:scaffolder Everything and all things related to the scaffolder project area area:search area:techdocs Related to the TechDocs Project Area size:huge Huge pull requests receive a lower priority for reviews. waiting-for:review The PR needs a review and will be visible in the review queue unless already assigned an owner.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant