Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3daff38
initial setup -- duplicated + package.json edited
theVedanta Dec 1, 2025
0e40281
simple preact updations
theVedanta Dec 15, 2025
722e05b
missed a React.ReactNode
theVedanta Dec 15, 2025
78cf64a
testing grunt work (preact library + other small issues + ErrorBounda…
theVedanta Dec 17, 2025
a9c5c75
missed a few
theVedanta Dec 17, 2025
8cc6ed5
Adds ErrorBoundary (from react-error-boundary, but scaled down for pr…
theVedanta Dec 26, 2025
088795b
useSuspenseQueries left -- removed the useQuery.promise tests
theVedanta Dec 27, 2025
0f5bdbc
forgot the console logs
theVedanta Dec 27, 2025
6d23454
useSuspenseQueries 2 resolved; tests done
theVedanta Dec 27, 2025
60502ad
Merge branch 'main' into pr/9935
TkDodo Dec 28, 2025
f2f73f9
Merge branch 'main' into preact-adapter
TkDodo Dec 28, 2025
460919e
ci: apply automated fixes
autofix-ci[bot] Dec 28, 2025
1a3afe6
Merge branch 'main' into preact-adapter
TkDodo Dec 28, 2025
05af042
fix: example
TkDodo Dec 28, 2025
4d5a0f0
fix: configs should be symlinks
TkDodo Dec 28, 2025
f451435
fix: sync versions for npm-run-all2
TkDodo Dec 28, 2025
b2e95fd
ref: re-sync runall2
TkDodo Dec 28, 2025
34f0262
ref: go back to 5.0.0
TkDodo Dec 28, 2025
4e366c4
ref: remove changelog
TkDodo Dec 28, 2025
3c6b541
react-query -> preact-query
TkDodo Dec 28, 2025
66605b1
remove use client directive + added the useSyncExternalStore (decoupl…
theVedanta Dec 28, 2025
c069be8
Merge branch 'preact-adapter' of https://github.com/theVedanta/query …
theVedanta Dec 28, 2025
445e37b
remove the react remnants
theVedanta Jan 1, 2026
bdc5d11
generate docs
theVedanta Jan 1, 2026
3e43af5
typescript eslint
theVedanta Jan 1, 2026
f1b1b78
docs
theVedanta Jan 1, 2026
9c72beb
vite config fix
theVedanta Jan 2, 2026
893b99c
docs now reference react docs (most of them atleast)
theVedanta Jan 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/framework/preact/graphql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: graphql
title: GraphQL
ref: docs/framework/react/graphql.md
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: background-fetching-indicators
title: Background Fetching Indicators
ref: docs/framework/react/guides/background-fetching-indicators.md
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/caching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: caching
title: Caching Examples
ref: docs/framework/react/guides/caching.md
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/default-query-function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: default-query-function
title: Default Query Function
ref: docs/framework/react/guides/default-query-function.md
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/dependent-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: dependent-queries
title: Dependent Queries
ref: docs/framework/react/guides/dependent-queries.md
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
57 changes: 57 additions & 0 deletions docs/framework/preact/guides/disabling-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
id: disabling-queries
title: Disabling/Pausing Queries
ref: docs/framework/react/guides/disabling-queries.md
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---

[//]: # 'Example2'

```tsx
function Todos() {
const [filter, setFilter] = useState('')

const { data } = useQuery({
queryKey: ['todos', filter],
queryFn: () => fetchTodos(filter),
// ⬇️ disabled as long as the filter is empty
enabled: !!filter,
})

return (
<div>
// 🚀 applying the filter will enable and execute the query
<FiltersForm onApply={setFilter} />
{data && <TodosTable data={data} />}
</div>
)
}
```
Comment on lines +10 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Add missing useState import in Example 2.

The code uses useState but doesn't import it. This will cause a runtime error when users copy and run this example. Example 3 below demonstrates the correct import pattern.

📝 Proposed fix to add the missing import
+import { useQuery } from '@tanstack/preact-query'
+import { useState } from 'preact/hooks'
+
 function Todos() {
   const [filter, setFilter] = useState('')
🤖 Prompt for AI Agents
In @docs/framework/preact/guides/disabling-queries.md around lines 63 - 82, The
Todos example is missing the useState import used in function Todos; add an
import for useState from 'preact/hooks' at the top of the example (same place
other hooks/imports are declared) so the useState call in Todos works correctly
when copied and run.


[//]: # 'Example2'

[//]: # 'Example3'

```tsx
import { skipToken, useQuery } from '@tanstack/react-query'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix incorrect package import in code example.

Line 36 imports from @tanstack/react-query, but this is a Preact documentation guide and should import from @tanstack/preact-query instead. This will cause confusion and errors for developers following this example.

🔧 Proposed fix
-import { skipToken, useQuery } from '@tanstack/react-query'
+import { skipToken, useQuery } from '@tanstack/preact-query'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { skipToken, useQuery } from '@tanstack/react-query'
import { skipToken, useQuery } from '@tanstack/preact-query'
🤖 Prompt for AI Agents
In @docs/framework/preact/guides/disabling-queries.md at line 36, The import
statement currently imports skipToken and useQuery from @tanstack/react-query;
update it to import these symbols from @tanstack/preact-query instead so the
Preact guide uses the correct package (replace the import of skipToken and
useQuery to come from @tanstack/preact-query).


function Todos() {
const [filter, setFilter] = useState<string | undefined>()

const { data } = useQuery({
queryKey: ['todos', filter],
// ⬇️ disabled as long as the filter is undefined or empty
queryFn: filter ? () => fetchTodos(filter) : skipToken,
})

return (
<div>
// 🚀 applying the filter will enable and execute the query
<FiltersForm onApply={setFilter} />
{data && <TodosTable data={data} />}
</div>
)
}
```

[//]: # 'Example3'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: does-this-replace-client-state
title: Does TanStack Query replace Redux, MobX or other global state managers?
ref: docs/framework/react/guides/does-this-replace-client-state
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: filters
title: Filters
ref: docs/framework/react/guides/filters
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/important-defaults.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: important-defaults
title: Important Defaults
ref: docs/framework/react/guides/important-defaults
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
65 changes: 65 additions & 0 deletions docs/framework/preact/guides/infinite-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
id: infinite-queries
title: Infinite Queries
ref: docs/framework/react/guides/infinite-queries
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---

[//]: # 'Example'

```tsx
import { useInfiniteQuery } from '@tanstack/preact-query'

function Projects() {
const fetchProjects = async ({ pageParam }) => {
const res = await fetch('/api/projects?cursor=' + pageParam)
return res.json()
}

const {
data,
error,
fetchNextPage,
hasNextPage,
isFetching,
isFetchingNextPage,
status,
} = useInfiniteQuery({
queryKey: ['projects'],
queryFn: fetchProjects,
initialPageParam: 0,
getNextPageParam: (lastPage, pages) => lastPage.nextCursor,
})

return status === 'pending' ? (
<p>Loading...</p>
) : status === 'error' ? (
<p>Error: {error.message}</p>
) : (
<>
{data.pages.map((group, i) => (
<div key={i}>
{group.data.map((project) => (
<p key={project.id}>{project.name}</p>
))}
<div/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix JSX closing tag syntax error.

Line 45 has a self-closing tag <div/> but should be a closing tag </div> to close the opening <div key={i}> from line 41.

🔧 Proposed fix
          {group.data.map((project) => (
            <p key={project.id}>{project.name}</p>
          ))}
-        <div/>
+        </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div/>
{group.data.map((project) => (
<p key={project.id}>{project.name}</p>
))}
</div>
🤖 Prompt for AI Agents
In @docs/framework/preact/guides/infinite-queries.md at line 45, There is a JSX
closing tag typo: replace the self-closing `<div/>` used to close the earlier
`div` (the `div` opened as <div key={i}>) with a proper closing tag `</div>` so
the element started in the `div key={i}` block is correctly closed.

))}
<div>
<button
onClick={() => fetchNextPage()}
disabled={!hasNextPage || isFetching}
>
{isFetchingNextPage
? 'Loading more...'
: hasNextPage
? 'Load More'
: 'Nothing more to load'}
</button>
</div>
<div>{isFetching && !isFetchingNextPage ? 'Fetching...' : null}</div>
</>
)
}
```

[//]: # 'Example'
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/initial-query-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: initial-query-data
title: Initial Query Data
ref: docs/framework/react/guides/initial-query-data
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/invalidations-from-mutations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: invalidations-from-mutations
title: Invalidations from Mutations
ref: docs/framework/react/guides/invalidations-from-mutations
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
11 changes: 11 additions & 0 deletions docs/framework/preact/guides/mutations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
id: mutations
title: Mutations
ref: docs/framework/react/guides/mutations
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---

[//]: # 'Info1'
[//]: # 'Info1'
[//]: # 'Example2'
[//]: # 'Example2'
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/network-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: network-mode
title: Network Mode
ref: docs/framework/react/guides/network-mode
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/optimistic-updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: optimistic-updates
title: Optimistic Updates
ref: docs/framework/react/guides/optimistic-updates
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
64 changes: 64 additions & 0 deletions docs/framework/preact/guides/paginated-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
id: paginated-queries
title: Paginated / Lagged Queries
ref: docs/framework/react/guides/paginated-queries
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---

[//]: # 'Example2'

```tsx
import { keepPreviousData, useQuery } from '@tanstack/react-query'
import { useState } from 'preact/hooks'

function Todos() {
const [page, setPage] = useState(0)

const fetchProjects = (page = 0) =>
fetch('/api/projects?page=' + page).then((res) => res.json())

const { isPending, isError, error, data, isFetching, isPlaceholderData } =
useQuery({
queryKey: ['projects', page],
queryFn: () => fetchProjects(page),
placeholderData: keepPreviousData,
})

return (
<div>
{isPending ? (
<div>Loading...</div>
) : isError ? (
<div>Error: {error.message}</div>
) : (
<div>
{data.projects.map((project) => (
<p key={project.id}>{project.name}</p>
))}
</div>
)}
<span>Current Page: {page + 1}</span>
<button
onClick={() => setPage((old) => Math.max(old - 1, 0))}
disabled={page === 0}
>
Previous Page
</button>
<button
onClick={() => {
if (!isPlaceholderData && data.hasMore) {
setPage((old) => old + 1)
}
}}
// Disable the Next Page button until we know a next page is available
disabled={isPlaceholderData || !data?.hasMore}
>
Next Page
</button>
{isFetching ? <span> Loading...</span> : null}
</div>
)
}
```

[//]: # 'Example2'
12 changes: 12 additions & 0 deletions docs/framework/preact/guides/parallel-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
id: parallel-queries
title: Parallel Queries
ref: docs/framework/react/guides/parallel-queries
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---

[//]: # 'Info'

> When using Preact Query with compat's Suspense, this pattern of parallelism does not work, since the first query would throw a promise internally and would suspend the component before the other queries run. To get around this, you'll either need to use the `useSuspenseQueries` hook (which is suggested) or orchestrate your own parallelism with separate components for each `useSuspenseQuery` instance.

[//]: # 'Info'
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/placeholder-query-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: placeholder-query-data
title: Placeholder Query Data
ref: docs/framework/react/guides/placeholder-query-data
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
51 changes: 51 additions & 0 deletions docs/framework/preact/guides/prefetching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: prefetching
title: Prefetching & Router Integration
ref: docs/framework/react/guides/prefetching
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---

[//]: # 'ExampleConditionally1'

```tsx
// This lazy loads the GraphFeedItem component, meaning
// it wont start loading until something renders it
import { lazy } from 'preact/iso'

const GraphFeedItem = lazy(() => import('./GraphFeedItem'))

function Feed() {
const { data, isPending } = useQuery({
queryKey: ['feed'],
queryFn: getFeed,
})

if (isPending) {
return 'Loading feed...'
}

return (
<>
{data.map((feedItem) => {
if (feedItem.type === 'GRAPH') {
return <GraphFeedItem key={feedItem.id} feedItem={feedItem} />
}

return <StandardFeedItem key={feedItem.id} feedItem={feedItem} />
})}
</>
)
}

// GraphFeedItem.tsx
function GraphFeedItem({ feedItem }) {
const { data, isPending } = useQuery({
queryKey: ['graph', feedItem.id],
queryFn: getGraphDataById,
})

...
}
```

[//]: # 'ExampleConditionally1'
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: queries
title: Queries
ref: docs/framework/react/guides/queries
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/query-cancellation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: query-cancellation
title: Query Cancellation
ref: docs/framework/react/guides/query-cancellation
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/query-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: query-functions
title: Query Functions
ref: docs/framework/react/guides/query-functions
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/query-invalidation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: query-invalidation
title: Query Invalidation
ref: docs/framework/react/guides/query-invalidation
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/query-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: query-keys
title: Query Keys
ref: docs/framework/react/guides/query-keys
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
6 changes: 6 additions & 0 deletions docs/framework/preact/guides/query-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: query-options
title: Query Options
ref: docs/framework/react/guides/query-options
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
---
Loading