Routes
Routes are pages in your single-page application
ScandiPWA uses react-router
and react-router-dom
to handle routing. The Router itself is a ScandiPWA component, defined in component/Router/Router.component.js
.
The components for the routes themselves are defined in the route
directory. The structure of each route is the same as any other component, but instead of being used throughout the application, they are used only in the router.
Special Cases
ScandiPWA allows you to create custom URL rewrites that don't match the standard routes. This is implemented in route/UrlRewrites
.
If neither the standard routes nor the URL rewrites resolve to anything, the user is shown an error message stating that no page has been found. This is implemented in route/NoMatchHandler
.
Example - Standard Route
The CartPage
is defined in route/CartPage
. It is added to the router:
Now, whenever the user visits /cart
, the CartPage
will be shown.
Example - URL Rewrite
The ProductPage is defined in route/ProductPage
. It is rendered when UrlRewrites
resolves an URL to a TYPE_PRODUCT
page:
Last updated