06 / 14

How can we handle dynamic segments of a route in declarative routing ?

If a path segment starts with : then it becomes a 'dynamic segment'. When the route matches the URL, the dynamic segment will be parsed from the URL and provided as params to other router APIs like useParams.

javascript
javascript
  1. 1

    You can have multiple dynamic segments in one route path.

  2. 2

    You can make a route segment optional by adding a ? to the end of the segment.