useIsRestoring / IsRestoringProvider
TheuseIsRestoring hook and IsRestoringProvider component are used to track whether queries are currently being restored from persisted state. This is useful for showing different UI during the restoration phase.
Import
IsRestoringProvider
A context provider component that tracks restoration state.Props
boolean
required
Whether queries are currently being restored
React.ReactNode
Child components that will have access to the restoration state
useIsRestoring
A hook that returns the current restoration state.Signature
Returns
boolean
true if queries are currently being restored, false otherwiseExamples
Basic Usage with Persistor
Conditional Loading States
Different UI During Restoration
Skeleton During Restoration
Combining with Query States
Restoration Progress
Manual Provider Control
Nested Providers
Disable Interactions During Restoration
Analytics Tracking
Use Cases
- Offline Persistence: Show different UI while restoring cached queries from local storage
- Loading States: Distinguish between initial load, restoration, and data fetching
- User Experience: Provide feedback during the restoration phase
- Performance: Defer non-critical operations until restoration is complete
- Analytics: Track how long restoration takes
Notes
IsRestoringProvideris a simple React context provideruseIsRestoringreads from this context- Defaults to
falseif no provider is found - Commonly used with persistence plugins like
@tanstack/react-query-persist-client - The restoration flag should be set to
falseonce persistence restoration completes - Multiple providers can be nested with inner providers overriding outer ones
- This is a simple boolean flag - you control when it’s
trueorfalse