Hook
useIsPathnameActive
Checks whether a pathname matches the current URL path, including nested routes.
Hook
05
Import
import { useIsPathnameActive } from "@swirski/ui";Preview
useIsPathnameActive
PreviewActive route helper
Usage
const active = useIsPathnameActive(
"/components",
"/components/button",
);Props
| Prop | Type | Default | Notes |
|---|---|---|---|
pathnameRequired | string | URL | - | Target pathname or URL to match. |
currentUrlRequired | string | URL | - | Current route URL or pathname. |
options.exact | boolean | false | Require an exact pathname match. |
Returns
| Value | Type | Notes |
|---|---|---|
active | boolean | True when currentUrl matches pathname or a nested child path. |