Documentation
Hooks
usePathname

usePathname

Return current pathname (without query) of LayoutRouter and refresh automatically when the route changes.

import { usePathname } from "narraleaf-react";
 
const pathname = usePathname(); // e.g. "/user/profile"

Definition

declare function usePathname(): string;

The hook internally subscribes to router.onChange, so the component re-renders whenever navigation occurs.

See also: useParamsuseQueryParams