matchPath
On this page

matchPath

Summary

Reference Documentation ↗

Performs pattern matching on a URL pathname and returns information about the match.

Signature

function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(  pattern: PathPattern<Path> | Path,  pathname: string, ): PathMatch<ParamKey> | null 

Params

pattern

The pattern to match against the URL pathname. This can be a string or a PathPattern object. If a string is provided, it will be treated as a pattern with caseSensitive set to false and end set to true.

pathname

The URL pathname to match against the pattern.

Returns

A path match object if the pattern matches the pathname, or null if it does not match.

Docs and examples CC 4.0
Edit