customers/, orders/, products/, …) are file-based via TanStack Router and live in @spree/dashboard/src/routes/. Custom pages have two mechanisms:
- File routes (packaged plugins — preferred): the plugin ships ordinary TanStack route files, and the host build compiles them into its typed route tree. Typed
<Link>s with no casts, route-level code splitting,validateSearch, loaders — full router citizenship. - Route registry (in-app & dynamic):
defineDashboardPlugin({ routes })entries matched at navigation time by a catch-all dispatcher at/_authenticated/$storeId/$. Use for host-app customizations (plugins.ts) and anything registered conditionally at runtime. File routes always win over the registry — the catch-all is the lowest-priority match.
File routes (packaged plugins)
Declare a routes directory in your plugin’s marker and put TanStack route files in it:- Commit the final composed path literal. Plugin routes mount under the dashboard’s
_authenticated/$storeIdlayout; the route generator verifies the literal (and would rewrite a wrong one). - The host regenerates its
routeTree.gen.tson every dev start and build from installed package versions — updating your plugin picks up new routes automatically (dev servers need a restart, same as installing a plugin). - Exclude
src/routesfrom your package’s standalonetsc—createFileRoutepaths only type-check against a generated tree, which exists in host programs. Develop against a dashboard host (the scaffold’s tsconfig ships this exclusion).
Route collisions
Two packages can’t own the same route path. If a plugin declares a path that another plugin — or a built-in dashboard page — already claims, the build fails before generating the tree with an error naming both packages, the path, and each file:Runtime route registry (in-app & dynamic)
Register from your host app’splugins.ts (or a plugin that genuinely needs runtime registration):
path is relative to /$storeId — the dispatcher prepends the prefix at match time. So /reports matches the URL /store_xyz/reports. The leading / is required.
Path parameters
TanStack-Router-style$name tokens match a single non-empty segment:
Receiving params
Your component receives three props from the dispatcher:searchParams is typed as Record<string, unknown> because the dispatcher can’t statically know your page’s shape. If you’re handing it to <ResourceTable>, cast to ResourceSearch:
Permission gating
Asubject on the route entry renders a 403 fallback (instead of the page) when the user lacks read permission:
subject on the nav entry so users without permission never see the link in the first place. The route subject is the defensive layer for direct URLs.
subject is a registry-route feature — the dispatcher applies it before rendering. File routes don’t pass through the dispatcher, so they gate themselves: check permissions inside the component with <Can> or usePermissions() from @spree/dashboard-core and render a fallback. Either way, this is UX only — the backend still authorizes every API call.
Layout
Custom routes inherit the dashboard’s_authenticated + $storeId layout (auth guard, sidebar, top bar, etc.) — your component renders inside the <Outlet />. Use <ResourceLayout> from @spree/dashboard-ui to get the same header/main/sidebar grid as core pages:
Linking to a registry route
Registry routes aren’t in the generated route tree, so links to them bypass static checking:$name token.
Order of operations
Routes register at module-load time. The dispatcher reads from the registry on every navigation, so route registration is much more forgiving than nav: even a route registered after first render works as soon as the user navigates to it. The only ordering rule is the usual i18n one — register your translation bundle above any registration that callsi18n.t(...) (see Translations).
Reference
RouteEntry— full type- Catch-all dispatcher source — see how matching works

