Skip to main content

useNavigationLoader

'use client'. Single-line delegate to useNavigationLoading() from NavigationLoadingContext.

Return shape (NavigationLoadingContextType)​

FieldMeaning
navigate(path, { scroll? })router.push wrapped in startTransition; no-ops when pathname === path; sets loading state immediately
isNavigatingUI should show progress bar / blocking chrome
targetPathDestination path while transition pending
isPendingMirrors React useTransition pending flag

Provider behavior (context)​

NavigationLoadingProvider clears loading when pathname changes or after 10s fallback timeout. Throws if hook used outside provider.

Consumers​

NavigationLoadingBar, InstantLink, and GlobalLoadingContext (calls navigate for coordinated loading).

Edge cases​

Duplicate navigation to current path is ignored. Timeout prevents stuck loading if router aborts.


Sources: src/lib/hooks/useNavigationLoader.ts, src/lib/context/NavigationLoadingContext.tsx