useNavigationType
Returns the current navigation action which describes how the router came to the current location, either by a pop, push, or replace on the history stack.
Return Value
The current navigation type:
"POP"- The user navigated using the browser back/forward buttons"PUSH"- A new entry was added to the history stack (e.g., via a link click ornavigate())"REPLACE"- The current entry in the history stack was replaced (e.g., vianavigate("/path", { replace: true }))
Type Declaration
Usage Examples
Track Navigation Method
Conditional Behavior Based on Navigation Type
Differentiate Fresh Navigation from History Navigation
Common Patterns
Combining with useLocation
Notes
- The navigation type is derived from the browser’s history API
- This hook must be used within a
<Router>component - The navigation type is available in all React Router modes (Declarative, Data, and Framework)
- Initial page loads typically have a navigation type of
"POP"
Related
useLocation- Get the current locationuseNavigate- Navigate programmaticallyLink- Declarative navigation (creates PUSH navigations by default)