Skip to content

Commit 0c44073

Browse files
Update docs and changeset
1 parent 7049e4b commit 0c44073

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

.changeset/pink-pots-jam.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
'@tanstack/svelte-query': major
55
---
66

7-
BREAKING: Migrate to svelte runes (svelte v5+). Please see documentation for migration guide.
7+
BREAKING: Migrate to svelte runes (signals). Requires [Svelte v5.25.0](https://github.com/sveltejs/svelte/releases/tag/svelte%405.25.0) or newer. Please see the [migration guide](https://tanstack.com/query/latest/docs/framework/svelte/migrate-from-v5-to-v6).

docs/framework/svelte/migrate-from-v5-to-v6.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Overview
22

3-
While Svelte v5 has legacy compatibility with the stores syntax from Svelte v3/v4, it has been somewhat buggy and unreliable for this TanStack Query adapter. The `@tanstack/svelte-query` v6 adapter fully migrates to runes syntax.
3+
While Svelte v5 has legacy compatibility with the stores syntax from Svelte v3/v4, it has been somewhat buggy and unreliable for this adapter. The `@tanstack/svelte-query` v6 adapter fully migrates to the runes syntax, which relies on signals. This rewrite should also simplify the code required to ensure your query inputs remain reactive.
44

55
## Installation
66

@@ -12,7 +12,7 @@ Run `pnpm add @tanstack/svelte-query@latest` (or your package manager's equivale
1212
1313
## Thunks
1414

15-
Like the Solid adapter, most functions for the Svelte adapter now require options to be provided as a "thunk" (`() => options`) to maintain reactivity.
15+
Like the Solid adapter, most functions for the Svelte adapter now require options to be provided as a "thunk" (`() => options`) to provide reactivity.
1616

1717
```diff
1818
-const query = createQuery({
@@ -39,6 +39,23 @@ Given the adapter no longer uses stores, it is no longer necessary to prefix wit
3939
{/if}
4040
```
4141

42+
## Reactivity
43+
44+
You previously needed to do some funky things with stores to achieve reactivity for inputs. This is no longer the case! You don't even need to wrap your query in a `$derived`.
45+
46+
```diff
47+
-const intervalMs = writable(1000)
48+
+let intervalMs = $state(1000)
49+
50+
-const query = createQuery(derived(intervalMs, ($intervalMs) => ({
51+
+const query = createQuery(() => ({
52+
queryKey: ['refetch'],
53+
queryFn: async () => await fetch('/api/data').then((r) => r.json()),
54+
refetchInterval: $intervalMs,
55+
-})))
56+
+}))
57+
```
58+
4259
## Disabling Legacy Mode
4360

4461
If your component has any stores, it might not properly switch to runes mode. You can ensure your application is using runes in two ways:

0 commit comments

Comments
 (0)