[]previous and next page

useMatch

The match a component renders under, or the one from names.

The match a component renders under, or the one from names. Reactive.

Import#

ts
import { useMatch } from "@shadow-js/router";

Signature#

ts
function useMatch<P extends RegisteredPath = RegisteredPath>(
  options: FromOptions<P> = {},
): Accessor<RenderedMatch | undefined>

Parameters#

Name Description
options from names the route.

Returns#

An accessor of the match, or undefined when it is not on screen.

Examples#

ts
import { useMatch } from "@shadow-js/router";
const match = useMatch({ from: "post" });
match()?.params; // the params of the "post" match, or undefined when it is not on screen