Skip to content
8 changes: 8 additions & 0 deletions .changeset/curly-ravens-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@tanstack/vue-db': minor
'@tanstack/react-db': minor
'@tanstack/svelte-db': patch
'@tanstack/db': patch
---

Add `useLiveInfiniteQuery` as a Vue binding over the shared live-query window controller. Align infinite-query behavior across React, Vue, and Svelte, including awaitable page fetches, safe page sizes, reactive page-depth preservation, ordered collection validation, shared input resolution, and shared-window cleanup.
2 changes: 2 additions & 0 deletions docs/framework/react/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const { data, pages, fetchNextPage, hasNextPage } = useLiveInfiniteQuery(
)
```

`fetchNextPage()` returns a promise that resolves after the page request settles. Failures are exposed through the returned `error` value and do not reject the promise.

**Note:** The dependency array is only available when using the query function variant, not when passing a pre-created collection.

### useLiveSuspenseQuery
Expand Down
41 changes: 41 additions & 0 deletions docs/framework/svelte/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,47 @@ The `useLiveQuery` utility creates a live query that automatically updates your

**Note:** With Svelte 5, `useLiveQuery` returns reactive values through getters. Access `query.data` and `query.isLoading` directly (no `$` prefix needed).

### useLiveInfiniteQuery

For ordered, paginated data with live updates, use `useLiveInfiniteQuery`:

```svelte
<script>
import { useLiveInfiniteQuery } from '@tanstack/svelte-db'
import { eq } from '@tanstack/db'

let category = $state('news')
const query = useLiveInfiniteQuery(
(q) =>
q
.from({ posts: postsCollection })
.where(({ posts }) => eq(posts.category, category))
.orderBy(({ posts }) => posts.createdAt, 'desc'),
{ pageSize: 20 },
[() => category],
)
</script>

{#each query.data as post (post.id)}
<article>{post.title}</article>
{/each}

{#if query.hasNextPage}
<button
disabled={query.isFetchingNextPage}
onclick={() => query.fetchNextPage()}
>
Load more
</button>
{/if}
```

`fetchNextPage()` returns a promise that resolves after the page request settles. Failures are exposed through `query.error` and do not reject the promise.

The query must include `orderBy`. The dependency array is available only with
the query-function form. You can also pass an ordered, pre-created live query
collection directly.

### Dependency Arrays

The `useLiveQuery` utility accepts an optional dependency array as its last parameter. When any value in the array changes, the query is recreated and re-executed.
Expand Down
43 changes: 43 additions & 0 deletions docs/framework/vue/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,49 @@ const { data, isLoading } = useLiveQuery((q) =>

**Note:** All return values (`data`, `isLoading`, `status`, etc.) are computed refs, so access them with `.value` in `<script>` but directly in `<template>`.

### useLiveInfiniteQuery

For ordered, paginated data with live updates, use `useLiveInfiniteQuery`:

```vue
<script setup>
import { ref } from 'vue'
import { useLiveInfiniteQuery } from '@tanstack/vue-db'
import { eq } from '@tanstack/db'

const category = ref('news')
const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
useLiveInfiniteQuery(
(q) =>
q
.from({ posts: postsCollection })
.where(({ posts }) => eq(posts.category, category.value))
.orderBy(({ posts }) => posts.createdAt, 'desc'),
{ pageSize: 20 },
[category],
)
</script>

<template>
<article v-for="post in data" :key="post.id">
{{ post.title }}
</article>
<button
v-if="hasNextPage"
:disabled="isFetchingNextPage"
@click="fetchNextPage()"
>
Load more
</button>
</template>
```

`fetchNextPage()` returns a promise that resolves after the page request settles. Failures are exposed through the returned `error` ref and do not reject the promise.

The query must include `orderBy`. The dependency array is available only with
the query-function form. You can also pass an ordered, pre-created live query
collection directly.

### Dependency Arrays

The `useLiveQuery` composable accepts an optional dependency array as its last parameter. When any reactive value in the array changes, the query is recreated and re-executed.
Expand Down
Loading
Loading