useMatches



The useMatches hook returns the router's complete presented array of RouteMatch objects regardless of its caller's position in the component tree. The array can include still-loading descendants or matches below a pending/error/not-found render boundary.

Options:

  • select: If supplied, this function will be called with the route matches and the return value will be returned from useMatches. This value will also be used to determine if the hook should re-render its parent component using shallow equality checks.

  • structuralSharing: Configures whether structural sharing is enabled for the value returned by select.

API Docs

Return

An array of RouteMatch objects (or selected value) for the matched route.