useMatches
react-router

useMatches

useMatches(): UIMatch[]

Returns the active route matches, useful for accessing loaderData for parent/child routes or the route "handle" property

Docs and examples CC 4.0