The useParentMatches hook returns all of the parent RouteMatch objects from the root down to the immediate parent of the current match in context. It does not include the current match, which can be obtained using the useMatch hook.
If the router has pending matches and they are showing their pending component fallbacks, pending matches are used instead of active matches.
The useParentMatches hook accepts an optional options object.
import { useParentMatches } from '@tanstack/react-router'
function Component() {
const parentMatches = useParentMatches()
// ^ [RouteMatch, RouteMatch, ...]
}