Skip to main content

shouldRevalidate

Optimizes data loading by allowing you to skip loader execution when it’s not necessary.

Signature

ShouldRevalidateFunctionArgs
required
Arguments passed to the shouldRevalidate function
boolean
  • true to run the loader
  • false to skip the loader and keep existing data

Default Behavior

By default, React Router revalidates (re-runs loaders) in these cases:
  • After an action is called (form submission)
  • When URL search params change
  • When a link is clicked to the same URL (user clicks “refresh”)
  • When params change for the route
React Router does NOT revalidate when:
  • Navigating to a different route with the same parent
  • Params haven’t changed
  • No action was called

Basic Example

Skip Revalidation on Specific Actions

Revalidate Based on Action Result

Skip Revalidation on Search Param Changes

Revalidate Only on Specific Param Changes

Time-Based Revalidation

Revalidate on Specific Form Methods

Inspect Action Status

Complex Example

Best Practices

Use the default behavior as a fallback to avoid missing important revalidations:
It’s better to revalidate unnecessarily than to show stale data:
Only add shouldRevalidate when loader is computationally expensive:
Ensure your revalidation logic doesn’t break data updates:

Common Patterns

Parent/Child Route Coordination

List/Detail Pattern

See Also