useCurrentMatches

useCurrentMatches returns the route matches for the current location.


Import

import { useCurrentMatches } from "@solidjs/router";

Type

interface RouteMatch extends PathMatch {
route: RouteDescription;
}
function useCurrentMatches(): () => RouteMatch[];

Parameters

useCurrentMatches takes no arguments.


Return value

  • Type: () => RouteMatch[]

Returns the route matches accessor.


Behavior

  • Matches are computed from route branches and the current pathname, after applying transformUrl when configured.
  • The accessor updates when the current location changes.

Examples

Basic usage

import { createMemo } from "solid-js";
import { useCurrentMatches } from "@solidjs/router";
function Breadcrumbs() {
const matches = useCurrentMatches();
const breadcrumbs = createMemo(() =>
matches().map((match) => match.route.info?.breadcrumb)
);
return <>{breadcrumbs().join(" / ")}</>;
}

Last updated: 5/6/26, 4:10 AMEdit this pageReport an issue with this page