Skip to content

Commit

Permalink
docs(svelte-query): add persist to basic example (#7807)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins authored Jul 28, 2024
1 parent fcac011 commit 99f1250
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion examples/svelte/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"test:types": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json"
},
"dependencies": {
"@tanstack/query-sync-storage-persister": "^5.51.15",
"@tanstack/svelte-query": "^5.51.15",
"@tanstack/svelte-query-devtools": "^5.51.15"
"@tanstack/svelte-query-devtools": "^5.51.15",
"@tanstack/svelte-query-persist-client": "^5.51.15"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
Expand Down
12 changes: 9 additions & 3 deletions examples/svelte/basic/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<script lang="ts">
import '../app.css'
import { browser } from '$app/environment'
import { QueryClientProvider, QueryClient } from '@tanstack/svelte-query'
import { QueryClient } from '@tanstack/svelte-query'
import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'
import { PersistQueryClientProvider } from '@tanstack/svelte-query-persist-client'
import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister'
const queryClient = new QueryClient({
defaultOptions: {
Expand All @@ -11,11 +13,15 @@
},
},
})
const persister = createSyncStoragePersister({
storage: browser ? window.localStorage : null,
})
</script>

<QueryClientProvider client={queryClient}>
<PersistQueryClientProvider client={queryClient} persistOptions={{ persister }}>
<main>
<slot />
</main>
<SvelteQueryDevtools />
</QueryClientProvider>
</PersistQueryClientProvider>
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 99f1250

Please sign in to comment.