React
useAnchorProgress
Use `useAnchorProgress` hook
There are two ways to set up a progress bar that is triggered during navigation:
- If the framework has a router that detects the start and end of navigation (like the Next.js Pages Directory router, for example), you can use the
useProgress
hook to trigger the progress bar at the start of navigation and stop it when you reach the target page. - If the framework has a router that doesn't detect the start and end of navigation (like the Next.js App Directory router, for example), you can use this
useAnchorProgress
hook to activate navigation detection based on<a>
elements in dom andwindow.history
.
Import
Usage
Parameters
Options
Prop | Type | Default |
---|---|---|
shallowRouting | boolean | false |
disableSameURL | boolean | true |
startPosition | number | 0 |
delay | number | 0 |
stopDelay | number | 0 |
targetPreprocessor | (url: URL) => URL | undefined |
disableAnchorClick | boolean | false |
startOnLoad | boolean | false |
forcedStopDelay | number | 0 |