Is there a way to hook into the router's match (client)?

Is there a way to hook into the router (client-side) to override router.location in the <Routes> component? I want to alter the matched route that I rewrote on the server using a middleware.
export const Routes = (props: RoutesProps) => {
const router = useRouter();
const parentRoute = useRoute();
const routeDefs = children(() => props.children) as unknown as () =>
| RouteDefinition
| RouteDefinition[];
const branches = createMemo(() =>
createBranches(routeDefs(), joinPaths(parentRoute.pattern, props.base || ""), Outlet)
);
const matches = createMemo(() => getRouteMatches(branches(), router.location.pathname));
//...
export const Routes = (props: RoutesProps) => {
const router = useRouter();
const parentRoute = useRoute();
const routeDefs = children(() => props.children) as unknown as () =>
| RouteDefinition
| RouteDefinition[];
const branches = createMemo(() =>
createBranches(routeDefs(), joinPaths(parentRoute.pattern, props.base || ""), Outlet)
);
const matches = createMemo(() => getRouteMatches(branches(), router.location.pathname));
//...
2 Replies
mdynnl
mdynnl2y ago
you can through <Router source={...} />
Jérémy
JérémyOP2y ago
Thanks. Hmm… would you have an example of usage?
Want results from more Discord servers?
Add your server