Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

useIsRestoring.md

35 lines899 Bytes

1---
2id: useIsRestoring
3title: useIsRestoring
4---
5​
6```ts
7function useIsRestoring(): Box<boolean>;
8```
9​
10Defined in: [packages/svelte-query/src/useIsRestoring.ts:23](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/useIsRestoring.ts#L23)
11​
12If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` function alongside it to
13check if a restore is currently in progress. `createQuery` and friends also check this internally to avoid
14race conditions between the restore and mounting queries.
15​
16## Returns
17​
18`Box`\<`boolean`\>
19​
20A reactive box β€” read `.current` for `true` while a persisted client is being restored, `false`
21otherwise.
22​
23## Example
24​
25```svelte
26<script lang="ts">
27 import { useIsRestoring } from '@tanstack/svelte-query'
28​
29 const isRestoring = useIsRestoring()
30</script>
31​
32{#if isRestoring.current}
33 <div>Restoring cached data...</div>
34{/if}
35```