useNavigation
Returns the current navigation state, defaulting to an “idle” navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or readFormData from a form navigation.
This hook only works in Data and Framework modes.
Signature
Parameters
None.Returns
An object describing the current navigation:
Usage
Global loading indicator
Show loading bar
Disable UI during navigation
Show submitting state
Optimistic UI with form data
Show destination
Common Patterns
Different states for loading and submitting
Detect specific action
Loading skeleton
Page transition animation
Navigation progress
Disable links during navigation
Form-specific loading
Navigation State Flow
Type Safety
Important Notes
Global state
useNavigation tracks the global navigation state. For component-specific operations that shouldn’t navigate, use useFetcher.
Idle state
When no navigation is in progress,state is "idle" and the other properties are undefined.
FormData availability
formData is only available during the "submitting" state for forms using POST, PUT, PATCH, or DELETE methods. GET form submissions go directly to "loading" state.
Related
useFetcher- Component-specific form submissions without navigationuseFetchers- Access all in-flight fetchersuseNavigation- Navigate programmaticallyForm- Form component