S
SolidJS5mo ago
ctrl-z

How to set route info for file routes?

I'm attempting to implement breadcrumb. I see the docs mentions a solution that involves useCurrentMatches and an info object. But how does one set such an object for file routes? Is there a special export similar to Remix's handle?
1 Reply
ctrl-z
ctrl-zOP4mo ago
In case someone else stumbles upon this and need to know: in the route file, you can export a route object like this:
import { type RouteDefinition } from "@solidjs/router"
...
export const route: RouteDefinition = {
info: {
test: "zzz",
},
}
import { type RouteDefinition } from "@solidjs/router"
...
export const route: RouteDefinition = {
info: {
test: "zzz",
},
}
Then access the info object like this
const matches = useCurrentMatches()
for (const m of matches()) {
console.log(m.route.info)
}
const matches = useCurrentMatches()
for (const m of matches()) {
console.log(m.route.info)
}

Did you find this page helpful?