diff --git a/docs/frontend-system/architecture/07-routes.md b/docs/frontend-system/architecture/07-routes.md
index 1639c8ece9..1e81b8485f 100644
--- a/docs/frontend-system/architecture/07-routes.md
+++ b/docs/frontend-system/architecture/07-routes.md
@@ -381,6 +381,8 @@ const detailsRouteRef = createSubRouteRef({
});
// plugins/catalog/src/plugin.ts
+import React from 'react';
+import { Routes, Route, Link } from 'react-router-dom';
import { createPlugin, createPageExtension, useRouteRef } from '@backstage/frontend-plugin-api';
import { rootRouteRef, detailsRouteRef } from './routes.ts';
@@ -391,19 +393,27 @@ const DetailsPage = () => (
);
const rootPage = createPageExtension({
- defaultPath: '/'
+ defaultPath: '/',
routeRef: rootRouteRef,
loader: async () => {
- const detailsRouteRef = useRouteRef(detailsRouteRef)();
+ const Component = () => {
+ const to = useRouteRef(detailsRouteRef)();
- return (
-
-
Index Page
-
- } />
-
-
- );
+ return (
+
+
Index Page
+ {/* Registering the details subroute */}
+
+ } />
+
+ {/* Linking to the details subroute */}
+ Details Subpage
+
+ );
+ };
+
+ return ;
+ },
}
});
@@ -419,3 +429,77 @@ export default createPlugin({
// plugins/catalog/src/index.ts
export { default } from './plugin';
```
+
+Subroutes can also receive parameters, here is an example:
+
+```tsx
+// plugins/catalog/src/routes.ts
+import {
+ createRouteRef,
+ createSubRouteRef,
+} from '@backstage/frontend-plugin-api';
+
+const rootRouteRef = createRouteRef();
+const detailsRouteRef = createSubRouteRef({
+ parent: rootRouteRef,
+ path: '/details/:name/:namespace/:kind',
+});
+
+// plugins/catalog/src/plugin.ts
+import React from 'react';
+import { Routes, Route, Link } from 'react-router-dom';
+import {
+ createPlugin,
+ createPageExtension,
+ useRouteRef,
+} from '@backstage/frontend-plugin-api';
+import { rootRouteRef, detailsRouteRef } from './routes.ts';
+
+const DetailsPage = () => (
+
+
Entity Details
+ {/* can get the entity ref from URL and load the entity data here */}
+
+);
+
+const rootPage = createPageExtension({
+ defaultPath: '/subroutes',
+ routeRef: rootRouteRef,
+ loader: async () => {
+ const Component = () => {
+ const detailsRoutePath = useRouteRef(detailsRouteRef)({
+ // Setting the details subroute params
+ name: 'entity1',
+ namespace: 'default',
+ kind: 'component',
+ });
+
+ return (
+
+
Index Page
+ {/* Registering the details subroute */}
+
+ } />
+
+ {/* Linking to the details subroute */}
+ Entity 1 Details Subpage
+
+ );
+ };
+
+ return ;
+ },
+});
+
+export default createPlugin({
+ id: 'catalog',
+ routes: {
+ root: rootRouteRef,
+ details: detailsRouteRef,
+ },
+ extensions: [rootPage],
+});
+
+// plugins/catalog/src/index.ts
+export { default } from './plugin';
+```