Skip to main content
The PageRoutes component and its sub-components are used to define routing for app pages. Use createPageRouter to wrap your route definitions, which returns a React component that handles routing.

Basic example

Here’s a complete example showing how to create multiple pages in your app with routing:

createPageRouter

The createPageRouter function accepts JSX route definitions and returns a React component that handles routing. Call it at the module level with your <PageRoutes> tree:

Parameters

Returns

A React component (PageRouter) that you render in your app to activate routing.

PageRoutes

The PageRoutes component is the container for route definitions. When used as the root element passed to createPageRouter, it defines the top-level routes. When nested inside another <PageRoutes>, it defines a group of sub-routes under a shared path prefix.

Props

PageRoutes.IndexRoute

The PageRoutes.IndexRoute component defines the home page (index route) of your app or a nested section. This is the page that will be rendered when users navigate to the base URL of the enclosing PageRoutes.

Props

PageRoutes.Route

The PageRoutes.Route component defines a named page route in your app. Users can navigate to these routes using the path specified in the path prop.

Props

PageRoutes.AnyRoute

The PageRoutes.AnyRoute component defines a catch-all route that will be rendered when no other routes match. This is useful for displaying a custom 404 or “page not found” message.

Props

Guidelines

  • DO: use createPageRouter to define your routes and render the returned component.
  • DO: use PageRoutes.IndexRoute to define your app’s home page.
  • DO: use meaningful path names that describe the page content (e.g., “/docs”, “/settings”, “/support”).
  • DO: include a PageRoutes.AnyRoute to handle unmatched routes gracefully.
  • DO: use layoutComponent to share common UI across groups of routes.
  • DO: assign an id to each route when you need to identify the active route in layout components.
Last modified on April 14, 2026