Blog slug: {match()?.params.slug}
+diff --git a/src/routes/solid-router/reference/primitives/use-match.mdx b/src/routes/solid-router/reference/primitives/use-match.mdx index 4c46cbe80..6dca9eceb 100644 --- a/src/routes/solid-router/reference/primitives/use-match.mdx +++ b/src/routes/solid-router/reference/primitives/use-match.mdx @@ -10,52 +10,143 @@ tags: - path - conditional - links -version: '1.0' +version: "1.0" description: >- Check if paths match current route with useMatch - create active navigation links, conditional rendering based on route matching. --- -`useMatch` takes an accessor that returns the path and creates a Memo that returns match information if the current path matches the provided path. -Useful for determining if a given path matches the current route. +The `useMatch` function checks whether the current path matches a provided path pattern. -```js -const match = useMatch(() => props.href); +## Import -return
; +```ts +import { useMatch } from "@solidjs/router"; ``` -As a second parameter, `useMatch` also accepts a group of `MatchFilters`. -These filteres allow for a more granular check. +## Type -The filters are the same used by the `= P extends string + ? { [K in PathParams
[number]]?: MatchFilter }
+ : Record Blog slug: {match()?.params.slug}`
+- **Required:** No
+
+An object where keys correspond to route parameter names and values define match filters.
+Each filter can be:
+
+- An array of allowed strings
+- A regular expression pattern
+- A function that receives the parameter value as a string and returns true if the parameter should match
+
+## Return value
+
+`useMatch` returns a memo containing a `PathMatch` object when the path matches, or `undefined` when there's no match.
+
+The `PathMatch` object contains:
+
+### `params`
+
+- **Type:** `Record