Skip to main content

useIsRestoring / IsRestoringProvider

The useIsRestoring 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 otherwise

Examples

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

  • IsRestoringProvider is a simple React context provider
  • useIsRestoring reads from this context
  • Defaults to false if no provider is found
  • Commonly used with persistence plugins like @tanstack/react-query-persist-client
  • The restoration flag should be set to false once 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 true or false