Skip to main content

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 read FormData from a form navigation.
This hook only works in Data and Framework modes.

Signature

Parameters

None.

Returns

Navigation
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

Form-specific loading

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.