Route configuration

The routing configuration is a hierarchical structure used to describe the entire Dojo application, associating ids and outlets to a routing path. The routing path can be nested using children which enables building a routing structure that can accurately reflect the requirements of the application.

The routing configuration API is constructed with the following properties:

  • id: string: The unique id of the route.
  • path: string: The routing path segment to match in the URL.
  • outlet: string: The outlet name for the route. This is used by the Outlet widget to determine what needs to be rendered.
  • defaultRoute: boolean (optional): Marks the outlet as default, the application will redirect to this route automatically if no route or an unknown route is found on application load.
  • defaultParams: { [index: string]: string } (optional): Associated default parameters (path and query), required if the default route has required params.
  • children: RouteConfig[] (optional): Nested child routing configuration.

src/routes.ts

  1. export default [
  2. {
  3. id: 'home',
  4. path: 'home',
  5. outlet: 'home',
  6. defaultRoute: true
  7. },
  8. {
  9. id: 'about',
  10. path: 'about',
  11. outlet: 'about-overview',
  12. children: [
  13. {
  14. id: 'about-services',
  15. path: '{services}',
  16. outlet: 'about'
  17. },
  18. {
  19. id: 'about-company',
  20. path: 'company',
  21. outlet: 'about'
  22. },
  23. {
  24. id: 'about-history',
  25. path: 'history',
  26. outlet: 'about'
  27. }
  28. ]
  29. }
  30. ];

This example would register the following paths and route ids:

URL PathRoute
/homehome
/aboutabout-overview
/about/companyabout-company
/about/historyabout-history
/about/knittingabout-services
/about/sewingabout-services

The about-services route has been registered to match any path after /about This is at odds with the other registered routes, about-company and about-history, however Dojo routing ensures that the correct routes is matched in these scenarios.