SolidJSS
SolidJSβ€’2y agoβ€’
7 replies
Parker Codes

Get array of matched nested routes

I'm using @solid/router and would like to create a way to build breadcrumbs based on the nested routes I'm in, similar to useMatches() in Remix. Even if it just returned the simple array of matched routes, I could assign a key to each route and find a simple way to get a title and icon from there for breadcrumbs. I've searched through GitHub and here in Discord to find previous conversations and none of them seemed to find a solution, or at least didn't check back in to share.

Has anyone done this or have good ideas of where to start building from scratch?

Here's an alternate solution, but I don't want to get into portals and pushing to the array from the routes themselves: https://stackblitz.com/edit/solidjs-templates-wwykia?file=src%2Froutes%2Fone%2Ftwo%2Fthree.tsx

Remix's useMatches(): https://remix.run/docs/en/1.19.3/hooks/use-matches
Could utilize RouteDefinition .info: https://github.com/solidjs/solid-start/discussions/537#discussioncomment-8833782
Was this page helpful?