--- title: matchPath --- # `matchPath`
Type declaration ```tsx declare function matchPath< ParamKey extends string = string >( pattern: PathPattern | string, pathname: string ): PathMatch | null; interface PathMatch { params: Params; pathname: string; pattern: PathPattern; } interface PathPattern { path: string; caseSensitive?: boolean; end?: boolean; } ```
`matchPath` matches a route path pattern against a URL pathname and returns information about the match. This is useful whenever you need to manually run the router's matching algorithm to determine if a route path matches or not. It returns `null` if the pattern does not match the given pathname. The [`useMatch` hook][usematch] uses this function internally to match a route path relative to the current location. [usematch]: ../hooks/use-match