1.8 KiB
1.8 KiB
Object Router
Purpose
Top-level frontend URL routes are declared through React Router object configuration instead of inline JSX route declarations.
Files
frontend/src/app/appRoutes.tsxfrontend/src/app/ModuleRouteGuard.tsxfrontend/src/app/shellOutletContext.tsfrontend/src/app/AppRouter.tsxfrontend/src/app/AppProviders.tsxfrontend/src/shared/constants/routes.tsfrontend/src/shared/constants/moduleRoutes.tsfrontend/src/pages/modules/
Runtime Shape
App.tsxrenders provider composition and the router only.AppProvidersowns global providers, includingBrowserRouter.AppRouterrendersuseRoutes(appRoutes).appRoutesowns top-level route objects and nested product module routes.APP_ROUTE_PATHSowns route path constants that are reused outside the router.MODULESowns module metadata, including each module route path.- Product route pages are loaded with
React.lazy. AppLayoutis the shared shell route element and passes shell props through outlet context.- Module navigation uses route navigation instead of local active-module state.
Rules
- Do not add individual
<Route>declarations toApp.tsx. - Keep route elements thin; product behavior belongs in business hooks.
- Reuse
APP_ROUTE_PATHS.loginfor auth-expired redirects. - Add route-config and module-route metadata tests when routes change.
- New product modules must define a route path and a lazy page adapter.
- Restricted direct product routes should render the 404 page. Scope-change navigation may replace an invalid current module route with the first accessible route for the new effective scope.
- Use object routes as the default pattern unless React Router data APIs require a later move to
createBrowserRouter.