diff --git a/docs/config.json b/docs/config.json
index 1263384fd3..11fa81a127 100644
--- a/docs/config.json
+++ b/docs/config.json
@@ -7002,6 +7002,18 @@
{
"label": "Devtools Embedded Panel",
"to": "framework/preact/examples/devtools-panel"
+ },
+ {
+ "label": "Star Wars",
+ "to": "framework/preact/examples/star-wars"
+ },
+ {
+ "label": "Rick And Morty",
+ "to": "framework/preact/examples/rick-morty"
+ },
+ {
+ "label": "Offline Queries and Mutations",
+ "to": "framework/preact/examples/offline"
}
]
}
diff --git a/examples/preact/offline/.gitignore b/examples/preact/offline/.gitignore
new file mode 100644
index 0000000000..4673b022e5
--- /dev/null
+++ b/examples/preact/offline/.gitignore
@@ -0,0 +1,27 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# production
+/build
+
+pnpm-lock.yaml
+yarn.lock
+package-lock.json
+
+# misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
diff --git a/examples/preact/offline/README.md b/examples/preact/offline/README.md
new file mode 100644
index 0000000000..1cf8892652
--- /dev/null
+++ b/examples/preact/offline/README.md
@@ -0,0 +1,6 @@
+# Example
+
+To run this example:
+
+- `npm install`
+- `npm run dev`
diff --git a/examples/preact/offline/eslint.config.js b/examples/preact/offline/eslint.config.js
new file mode 100644
index 0000000000..b39d2be6c9
--- /dev/null
+++ b/examples/preact/offline/eslint.config.js
@@ -0,0 +1,20 @@
+// @ts-check
+
+import { tanstackConfig } from '@tanstack/eslint-config'
+import pluginQuery from '@tanstack/eslint-plugin-query'
+// @ts-ignore: no types for eslint-config-preact
+import preact from 'eslint-config-preact'
+import { defineConfig } from 'eslint/config'
+
+export default defineConfig([
+ ...preact,
+ ...tanstackConfig,
+ ...pluginQuery.configs['flat/recommended-strict'],
+ {
+ rules: {
+ 'no-duplicate-imports': 'off',
+ 'no-redeclare': 'off',
+ 'no-unused-vars': 'off',
+ },
+ },
+])
diff --git a/examples/preact/offline/index.html b/examples/preact/offline/index.html
new file mode 100644
index 0000000000..f3812487ad
--- /dev/null
+++ b/examples/preact/offline/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+ TanStack Query Preact Offline Example App
+
+
+ You need to enable JavaScript to run this app.
+
+
+
+
diff --git a/examples/preact/offline/package.json b/examples/preact/offline/package.json
new file mode 100644
index 0000000000..8dc112e81e
--- /dev/null
+++ b/examples/preact/offline/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "@tanstack/query-example-preact-offline",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "preview": "vite preview",
+ "test:eslint": "eslint ./src",
+ "test:types": "tsc --noEmit"
+ },
+ "dependencies": {
+ "@tanstack/preact-query": "^5.105.0",
+ "@tanstack/preact-query-devtools": "^5.105.0",
+ "@tanstack/preact-query-persist-client": "^5.105.0",
+ "@tanstack/query-async-storage-persister": "^5.105.0",
+ "@zag-js/preact": "^1.46.0",
+ "@zag-js/toast": "^1.46.0",
+ "msw": "^2.15.0",
+ "preact": "^11.0.1",
+ "preact-iso": "^2.12.2"
+ },
+ "devDependencies": {
+ "@preact/preset-vite": "^2.10.6",
+ "@tanstack/eslint-plugin-query": "^5.105.0",
+ "eslint": "^9.36.0",
+ "eslint-config-preact": "^2.0.0",
+ "typescript": "^5.9.3",
+ "vite": "^8.3.1"
+ },
+ "msw": {
+ "workerDirectory": [
+ "public"
+ ]
+ }
+}
diff --git a/examples/preact/offline/public/emblem-light.svg b/examples/preact/offline/public/emblem-light.svg
new file mode 100644
index 0000000000..a58e69ad5e
--- /dev/null
+++ b/examples/preact/offline/public/emblem-light.svg
@@ -0,0 +1,13 @@
+
+
+
+ emblem-light
+ Created with Sketch.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/preact/offline/public/mockServiceWorker.js b/examples/preact/offline/public/mockServiceWorker.js
new file mode 100644
index 0000000000..0c970efc96
--- /dev/null
+++ b/examples/preact/offline/public/mockServiceWorker.js
@@ -0,0 +1,361 @@
+/* eslint-disable */
+/* tslint:disable */
+
+/**
+ * Mock Service Worker.
+ * @see https://github.com/mswjs/msw
+ * - Please do NOT modify this file.
+ */
+
+const PACKAGE_VERSION = '2.15.0'
+const INTEGRITY_CHECKSUM = '03cb67ac84128e63d7cd722a6e5b7f1e'
+const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
+const activeClientIds = new Set()
+
+addEventListener('install', function () {
+ self.skipWaiting()
+})
+
+addEventListener('activate', function (event) {
+ event.waitUntil(self.clients.claim())
+})
+
+addEventListener('message', async function (event) {
+ const clientId = Reflect.get(event.source || {}, 'id')
+
+ if (!clientId || !self.clients) {
+ return
+ }
+
+ const client = await self.clients.get(clientId)
+
+ if (!client) {
+ return
+ }
+
+ const allClients = await self.clients.matchAll({
+ type: 'window',
+ })
+
+ switch (event.data) {
+ case 'KEEPALIVE_REQUEST': {
+ sendToClient(client, {
+ type: 'KEEPALIVE_RESPONSE',
+ })
+ break
+ }
+
+ case 'INTEGRITY_CHECK_REQUEST': {
+ sendToClient(client, {
+ type: 'INTEGRITY_CHECK_RESPONSE',
+ payload: {
+ packageVersion: PACKAGE_VERSION,
+ checksum: INTEGRITY_CHECKSUM,
+ },
+ })
+ break
+ }
+
+ case 'MOCK_ACTIVATE': {
+ activeClientIds.add(clientId)
+
+ sendToClient(client, {
+ type: 'MOCKING_ENABLED',
+ payload: {
+ client: {
+ id: client.id,
+ frameType: client.frameType,
+ },
+ },
+ })
+ break
+ }
+
+ case 'CLIENT_CLOSED': {
+ activeClientIds.delete(clientId)
+
+ const remainingClients = allClients.filter((client) => {
+ return client.id !== clientId
+ })
+
+ // Unregister itself when there are no more clients
+ if (remainingClients.length === 0) {
+ self.registration.unregister()
+ }
+
+ break
+ }
+ }
+})
+
+addEventListener('fetch', function (event) {
+ const requestInterceptedAt = Date.now()
+
+ // Bypass navigation requests.
+ if (event.request.mode === 'navigate') {
+ return
+ }
+
+ // Opening the DevTools triggers the "only-if-cached" request
+ // that cannot be handled by the worker. Bypass such requests.
+ if (
+ event.request.cache === 'only-if-cached' &&
+ event.request.mode !== 'same-origin'
+ ) {
+ return
+ }
+
+ // Bypass all requests when there are no active clients.
+ // Prevents the self-unregistered worked from handling requests
+ // after it's been terminated (still remains active until the next reload).
+ if (activeClientIds.size === 0) {
+ return
+ }
+
+ const requestId = crypto.randomUUID()
+ event.respondWith(handleRequest(event, requestId, requestInterceptedAt))
+})
+
+/**
+ * @param {FetchEvent} event
+ * @param {string} requestId
+ * @param {number} requestInterceptedAt
+ */
+async function handleRequest(event, requestId, requestInterceptedAt) {
+ const client = await resolveMainClient(event)
+ const requestCloneForEvents = event.request.clone()
+ const response = await getResponse(
+ event,
+ client,
+ requestId,
+ requestInterceptedAt,
+ )
+
+ // Send back the response clone for the "response:*" life-cycle events.
+ // Ensure MSW is active and ready to handle the message, otherwise
+ // this message will pend indefinitely.
+ if (client && activeClientIds.has(client.id)) {
+ const serializedRequest = await serializeRequest(requestCloneForEvents)
+
+ // Omit the body of server-sent event stream responses.
+ // Cloning such responses would prevent client-side stream cancelations
+ // from reaching the original stream (a teed stream only cancels its
+ // source once both of its branches cancel) and would buffer the
+ // entire stream into the unconsumed clone indefinitely.
+ const isEventStreamResponse = response.headers
+ .get('content-type')
+ ?.toLowerCase()
+ .startsWith('text/event-stream')
+
+ // Clone the response so both the client and the library could consume it.
+ const responseClone = isEventStreamResponse ? null : response.clone()
+
+ sendToClient(
+ client,
+ {
+ type: 'RESPONSE',
+ payload: {
+ isMockedResponse: IS_MOCKED_RESPONSE in response,
+ request: {
+ id: requestId,
+ ...serializedRequest,
+ },
+ response: {
+ type: response.type,
+ status: response.status,
+ statusText: response.statusText,
+ headers: Object.fromEntries(response.headers.entries()),
+ body: responseClone ? responseClone.body : null,
+ },
+ },
+ },
+ responseClone && responseClone.body
+ ? [serializedRequest.body, responseClone.body]
+ : [],
+ )
+ }
+
+ return response
+}
+
+/**
+ * Resolve the main client for the given event.
+ * Client that issues a request doesn't necessarily equal the client
+ * that registered the worker. It's with the latter the worker should
+ * communicate with during the response resolving phase.
+ * @param {FetchEvent} event
+ * @returns {Promise}
+ */
+async function resolveMainClient(event) {
+ const client = await self.clients.get(event.clientId)
+
+ if (activeClientIds.has(event.clientId)) {
+ return client
+ }
+
+ if (client?.frameType === 'top-level') {
+ return client
+ }
+
+ const allClients = await self.clients.matchAll({
+ type: 'window',
+ })
+
+ return allClients
+ .filter((client) => {
+ // Get only those clients that are currently visible.
+ return client.visibilityState === 'visible'
+ })
+ .find((client) => {
+ // Find the client ID that's recorded in the
+ // set of clients that have registered the worker.
+ return activeClientIds.has(client.id)
+ })
+}
+
+/**
+ * @param {FetchEvent} event
+ * @param {Client | undefined} client
+ * @param {string} requestId
+ * @param {number} requestInterceptedAt
+ * @returns {Promise}
+ */
+async function getResponse(event, client, requestId, requestInterceptedAt) {
+ // Clone the request because it might've been already used
+ // (i.e. its body has been read and sent to the client).
+ const requestClone = event.request.clone()
+
+ function passthrough() {
+ // Cast the request headers to a new Headers instance
+ // so the headers can be manipulated with.
+ const headers = new Headers(requestClone.headers)
+
+ // Remove the "accept" header value that marked this request as passthrough.
+ // This prevents request alteration and also keeps it compliant with the
+ // user-defined CORS policies.
+ const acceptHeader = headers.get('accept')
+ if (acceptHeader) {
+ const values = acceptHeader.split(',').map((value) => value.trim())
+ const filteredValues = values.filter(
+ (value) => value !== 'msw/passthrough',
+ )
+
+ if (filteredValues.length > 0) {
+ headers.set('accept', filteredValues.join(', '))
+ } else {
+ headers.delete('accept')
+ }
+ }
+
+ return fetch(requestClone, { headers })
+ }
+
+ // Bypass mocking when the client is not active.
+ if (!client) {
+ return passthrough()
+ }
+
+ // Bypass initial page load requests (i.e. static assets).
+ // The absence of the immediate/parent client in the map of the active clients
+ // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
+ // and is not ready to handle requests.
+ if (!activeClientIds.has(client.id)) {
+ return passthrough()
+ }
+
+ // Notify the client that a request has been intercepted.
+ const serializedRequest = await serializeRequest(event.request)
+ const clientMessage = await sendToClient(
+ client,
+ {
+ type: 'REQUEST',
+ payload: {
+ id: requestId,
+ interceptedAt: requestInterceptedAt,
+ ...serializedRequest,
+ },
+ },
+ [serializedRequest.body],
+ )
+
+ switch (clientMessage.type) {
+ case 'MOCK_RESPONSE': {
+ return respondWithMock(clientMessage.data)
+ }
+
+ case 'PASSTHROUGH': {
+ return passthrough()
+ }
+ }
+
+ return passthrough()
+}
+
+/**
+ * @param {Client} client
+ * @param {any} message
+ * @param {Array} transferrables
+ * @returns {Promise}
+ */
+function sendToClient(client, message, transferrables = []) {
+ return new Promise((resolve, reject) => {
+ const channel = new MessageChannel()
+
+ channel.port1.onmessage = (event) => {
+ if (event.data && event.data.error) {
+ return reject(event.data.error)
+ }
+
+ resolve(event.data)
+ }
+
+ client.postMessage(message, [
+ channel.port2,
+ ...transferrables.filter(Boolean),
+ ])
+ })
+}
+
+/**
+ * @param {Response} response
+ * @returns {Response}
+ */
+function respondWithMock(response) {
+ // Setting response status code to 0 is a no-op.
+ // However, when responding with a "Response.error()", the produced Response
+ // instance will have status code set to 0. Since it's not possible to create
+ // a Response instance with status code 0, handle that use-case separately.
+ if (response.status === 0) {
+ return Response.error()
+ }
+
+ const mockedResponse = new Response(response.body, response)
+
+ Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
+ value: true,
+ enumerable: true,
+ })
+
+ return mockedResponse
+}
+
+/**
+ * @param {Request} request
+ */
+async function serializeRequest(request) {
+ return {
+ url: request.url,
+ mode: request.mode,
+ method: request.method,
+ headers: Object.fromEntries(request.headers.entries()),
+ cache: request.cache,
+ credentials: request.credentials,
+ destination: request.destination,
+ integrity: request.integrity,
+ redirect: request.redirect,
+ referrer: request.referrer,
+ referrerPolicy: request.referrerPolicy,
+ body: await request.arrayBuffer(),
+ keepalive: request.keepalive,
+ }
+}
diff --git a/examples/preact/offline/src/App.tsx b/examples/preact/offline/src/App.tsx
new file mode 100644
index 0000000000..8182739edf
--- /dev/null
+++ b/examples/preact/offline/src/App.tsx
@@ -0,0 +1,244 @@
+import { useState } from 'preact/hooks'
+import {
+ MutationCache,
+ QueryClient,
+ onlineManager,
+ useIsRestoring,
+ useMutation,
+ useQuery,
+} from '@tanstack/preact-query'
+import { PreactQueryDevtools } from '@tanstack/preact-query-devtools'
+import { PersistQueryClientProvider } from '@tanstack/preact-query-persist-client'
+import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
+import { LocationProvider, Route, Router, useRoute } from 'preact-iso'
+
+import { moviesMutations, moviesQueries } from './services/movies/queries'
+import { Toaster, toaster } from './Toaster'
+
+const persister = createAsyncStoragePersister({
+ storage: window.localStorage,
+})
+
+const queryClient = new QueryClient({
+ defaultOptions: {
+ queries: {
+ gcTime: 24 * 60 * 60 * 1000, // 24 hours
+ staleTime: 2000,
+ retry: 0,
+ },
+ },
+ // configure global cache callbacks to show error toast notifications
+ mutationCache: new MutationCache({
+ onError: (error) => {
+ toaster.error({ title: error.message })
+ },
+ }),
+})
+
+// we need a default mutation function so that paused mutations can resume after a page reload
+queryClient.setMutationDefaults(moviesQueries.all(), {
+ ...moviesMutations.update(),
+ onSuccess: (data) => {
+ toaster.success({ title: data.message })
+ },
+})
+
+export default function App() {
+ return (
+ {
+ // resume mutations after initial restore from localStorage was successful
+ queryClient.resumePausedMutations().then(() => {
+ queryClient.invalidateQueries()
+ })
+ }}
+ >
+
+
+
+
+
+
+
+
+
+ )
+}
+
+function List() {
+ const isRestoring = useIsRestoring()
+ const moviesQuery = useQuery(moviesQueries.list())
+
+ if (moviesQuery.isLoading) {
+ return 'Loading...'
+ }
+
+ if (moviesQuery.data) {
+ return (
+
+
Movies
+
+ Try to mock offline behavior with the button in the devtools. You can
+ navigate around as long as there is already data in the cache. You'll
+ get a refetch as soon as you go online again.
+
+
+
+ Updated at: {new Date(moviesQuery.data.ts).toLocaleTimeString()}
+
+
{moviesQuery.isFetching && 'fetching...'}
+
+ )
+ }
+
+ if (moviesQuery.isError) {
+ return (
+
+
Couldn't load movies!
+
{moviesQuery.error.message}
+
+ )
+ }
+
+ // query will be in 'idle' fetchStatus while restoring from localStorage
+ return null
+}
+
+function Detail() {
+ const { movieId } = useRoute().params
+ const movieQuery = useQuery(moviesQueries.detail(movieId))
+
+ const [commentDraft, setCommentDraft] = useState()
+
+ const updateMovie = useMutation({
+ ...moviesMutations.update(),
+ mutationKey: moviesQueries.detail(movieId).queryKey,
+ onMutate: async (variables) => {
+ await queryClient.cancelQueries({
+ queryKey: moviesQueries.detail(movieId).queryKey,
+ })
+ const { queryKey } = moviesQueries.detail(movieId)
+ const previousData = queryClient.getQueryData(queryKey)
+
+ // remove local state so that server state is taken instead
+ setCommentDraft(undefined)
+
+ queryClient.setQueryData(
+ queryKey,
+ (old) =>
+ old && {
+ ...old,
+ movie: {
+ ...old.movie,
+ comment: variables.comment,
+ },
+ },
+ )
+
+ return { previousData }
+ },
+ onError: (_, __, onMutateResult) => {
+ queryClient.setQueryData(
+ moviesQueries.detail(movieId).queryKey,
+ onMutateResult?.previousData,
+ )
+ },
+ onSettled: () => {
+ queryClient.invalidateQueries({
+ queryKey: moviesQueries.detail(movieId).queryKey,
+ })
+ },
+ })
+
+ const comment = commentDraft ?? movieQuery.data?.movie.comment
+
+ if (movieQuery.isLoading) {
+ return 'Loading...'
+ }
+
+ function submitForm(event: SubmitEvent) {
+ event.preventDefault()
+
+ if (comment === undefined) {
+ return
+ }
+
+ updateMovie.mutate({
+ id: movieId,
+ comment,
+ })
+ }
+
+ if (movieQuery.data) {
+ return (
+
+ )
+ }
+
+ if (movieQuery.isError) {
+ return (
+
+
Back
+
Couldn't load movie!
+
{movieQuery.error.message}
+
+ )
+ }
+
+ if (movieQuery.isPaused) {
+ return "We're offline and have no data to show :("
+ }
+
+ return null
+}
diff --git a/examples/preact/offline/src/Toaster.tsx b/examples/preact/offline/src/Toaster.tsx
new file mode 100644
index 0000000000..c6459084b4
--- /dev/null
+++ b/examples/preact/offline/src/Toaster.tsx
@@ -0,0 +1,50 @@
+import { useId } from 'preact/hooks'
+import { normalizeProps, useMachine } from '@zag-js/preact'
+import * as toast from '@zag-js/toast'
+
+import './toaster.css'
+
+export const toaster = toast.createStore({
+ placement: 'top',
+ overlap: true,
+})
+
+function Toast({
+ toast: options,
+ parent,
+ index,
+}: {
+ toast: toast.Options
+ parent: toast.GroupService
+ index: number
+}) {
+ const service = useMachine(toast.machine, { ...options, parent, index })
+ const api = toast.connect(service, normalizeProps)
+
+ return (
+
+ {api.title}
+
+ )
+}
+
+export function Toaster() {
+ const service = useMachine(toast.group.machine, {
+ id: useId(),
+ store: toaster,
+ })
+ const api = toast.group.connect(service, normalizeProps)
+
+ return (
+
+ {api.getToasts().map((options, index) => (
+
+ ))}
+
+ )
+}
diff --git a/examples/preact/offline/src/index.tsx b/examples/preact/offline/src/index.tsx
new file mode 100644
index 0000000000..920195ef8f
--- /dev/null
+++ b/examples/preact/offline/src/index.tsx
@@ -0,0 +1,15 @@
+import { render } from 'preact'
+import App from './App'
+import { worker } from './mocks'
+
+const rootElement = document.getElementById('root')
+if (!rootElement) throw new Error('Missing #root element')
+
+worker.start().then(() => {
+ render(
+ ,
+ rootElement,
+ )
+})
diff --git a/examples/preact/offline/src/mocks.ts b/examples/preact/offline/src/mocks.ts
new file mode 100644
index 0000000000..db04863a11
--- /dev/null
+++ b/examples/preact/offline/src/mocks.ts
@@ -0,0 +1,60 @@
+import { HttpResponse, delay, http, passthrough } from 'msw'
+import { setupWorker } from 'msw/browser'
+
+const movies = [
+ {
+ id: '1',
+ title: 'Guardians of the Galaxy',
+ comment: '',
+ },
+ {
+ id: '2',
+ title: 'Wall-E',
+ comment: '',
+ },
+]
+
+export const worker = setupWorker(
+ http.get('/movies', async () => {
+ await delay(500)
+ return HttpResponse.json({
+ ts: Date.now(),
+ movies: movies.map(({ id, title }) => ({ id, title })),
+ })
+ }),
+
+ http.get('/movies/:id', async ({ params }) => {
+ const { id } = params
+
+ const movie = movies.find((item) => item.id === id)
+
+ if (!movie) {
+ return new HttpResponse(`Movie with id ${id} not found`, {
+ status: 404,
+ })
+ }
+
+ await delay(500)
+ return HttpResponse.json({ ts: Date.now(), movie })
+ }),
+
+ http.post<{ id: string }, { comment: string }>(
+ '/movies/:id',
+ async ({ request, params }) => {
+ const { id } = params
+ const body = await request.json()
+ const { comment } = body
+
+ movies.forEach((movie) => {
+ if (movie.id === id) {
+ movie.comment = comment.toUpperCase()
+ }
+ })
+
+ await delay(500)
+ return HttpResponse.json({ message: `Successfully updated movie ${id}` })
+ },
+ ),
+ http.get('*.js', () => passthrough()),
+ http.get('*.svg', () => passthrough()),
+)
diff --git a/examples/preact/offline/src/services/movies/api.ts b/examples/preact/offline/src/services/movies/api.ts
new file mode 100644
index 0000000000..06c61618ad
--- /dev/null
+++ b/examples/preact/offline/src/services/movies/api.ts
@@ -0,0 +1,36 @@
+import type {
+ MovieResponse,
+ MoviesResponse,
+ UpdateMovieResponse,
+} from './types'
+
+export const moviesAPI = {
+ getMovie: async (id: string): Promise => {
+ const response = await fetch(`/movies/${id}`)
+ if (!response.ok) {
+ throw new Error(await response.text())
+ }
+ return await response.json()
+ },
+ getMovies: async (): Promise => {
+ const response = await fetch('/movies')
+ if (!response.ok) {
+ throw new Error(await response.text())
+ }
+ return await response.json()
+ },
+ updateMovie: async (
+ id: string,
+ comment: string,
+ ): Promise => {
+ const response = await fetch(`/movies/${id}`, {
+ method: 'POST',
+ body: JSON.stringify({ comment }),
+ headers: { 'Content-Type': 'application/json' },
+ })
+ if (!response.ok) {
+ throw new Error(await response.text())
+ }
+ return await response.json()
+ },
+}
diff --git a/examples/preact/offline/src/services/movies/queries.ts b/examples/preact/offline/src/services/movies/queries.ts
new file mode 100644
index 0000000000..026c5ead1e
--- /dev/null
+++ b/examples/preact/offline/src/services/movies/queries.ts
@@ -0,0 +1,32 @@
+import { mutationOptions, queryOptions } from '@tanstack/preact-query'
+import { moviesAPI } from './api'
+
+export const moviesQueries = {
+ all: () => ['movies'] as const,
+ list: () =>
+ queryOptions({
+ queryKey: [...moviesQueries.all(), 'list'] as const,
+ queryFn: () => moviesAPI.getMovies(),
+ }),
+ detail: (id: string) =>
+ queryOptions({
+ queryKey: [...moviesQueries.all(), 'detail', id] as const,
+ queryFn: () => moviesAPI.getMovie(id),
+ }),
+}
+
+export const moviesMutations = {
+ update: () =>
+ mutationOptions({
+ mutationFn: async (
+ { id, comment }: { id: string; comment: string },
+ context,
+ ) => {
+ // to avoid clashes with our optimistic update when an offline mutation continues
+ await context.client.cancelQueries({
+ queryKey: moviesQueries.detail(id).queryKey,
+ })
+ return moviesAPI.updateMovie(id, comment)
+ },
+ }),
+}
diff --git a/examples/preact/offline/src/services/movies/types.ts b/examples/preact/offline/src/services/movies/types.ts
new file mode 100644
index 0000000000..0309450ca4
--- /dev/null
+++ b/examples/preact/offline/src/services/movies/types.ts
@@ -0,0 +1,19 @@
+export type Movie = {
+ comment: string
+ id: string
+ title: string
+}
+
+export type MovieResponse = {
+ ts: number
+ movie: Movie
+}
+
+export type MoviesResponse = {
+ ts: number
+ movies: Array>
+}
+
+export type UpdateMovieResponse = {
+ message: string
+}
diff --git a/examples/preact/offline/src/toaster.css b/examples/preact/offline/src/toaster.css
new file mode 100644
index 0000000000..7c86f06fb2
--- /dev/null
+++ b/examples/preact/offline/src/toaster.css
@@ -0,0 +1,24 @@
+[data-scope='toast'][data-part='root'] {
+ translate: var(--x) var(--y);
+ scale: var(--scale);
+ z-index: var(--z-index);
+ height: var(--height);
+ opacity: var(--opacity);
+ will-change: translate, opacity, scale;
+ transition:
+ translate 400ms,
+ scale 400ms,
+ opacity 400ms;
+ padding: 12px 16px;
+ border-radius: 8px;
+ background: white;
+ box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
+}
+
+[data-scope='toast'][data-part='root'][data-type='success'] {
+ border-left: 4px solid #61d345;
+}
+
+[data-scope='toast'][data-part='root'][data-type='error'] {
+ border-left: 4px solid #ff4b4b;
+}
diff --git a/examples/preact/offline/tsconfig.json b/examples/preact/offline/tsconfig.json
new file mode 100644
index 0000000000..883cc3ab4f
--- /dev/null
+++ b/examples/preact/offline/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+ "allowJs": true,
+ "checkJs": true,
+ "moduleResolution": "Bundler",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "react-jsx",
+ "jsxImportSource": "preact",
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["src", "eslint.config.js"]
+}
diff --git a/examples/preact/offline/vite.config.ts b/examples/preact/offline/vite.config.ts
new file mode 100644
index 0000000000..bfe110c059
--- /dev/null
+++ b/examples/preact/offline/vite.config.ts
@@ -0,0 +1,6 @@
+import { defineConfig } from 'vite'
+import preact from '@preact/preset-vite'
+
+export default defineConfig({
+ plugins: [preact()],
+})
diff --git a/examples/preact/rick-morty/.gitignore b/examples/preact/rick-morty/.gitignore
new file mode 100644
index 0000000000..4673b022e5
--- /dev/null
+++ b/examples/preact/rick-morty/.gitignore
@@ -0,0 +1,27 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# production
+/build
+
+pnpm-lock.yaml
+yarn.lock
+package-lock.json
+
+# misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
diff --git a/examples/preact/rick-morty/README.md b/examples/preact/rick-morty/README.md
new file mode 100644
index 0000000000..1cf8892652
--- /dev/null
+++ b/examples/preact/rick-morty/README.md
@@ -0,0 +1,6 @@
+# Example
+
+To run this example:
+
+- `npm install`
+- `npm run dev`
diff --git a/examples/preact/rick-morty/eslint.config.js b/examples/preact/rick-morty/eslint.config.js
new file mode 100644
index 0000000000..b39d2be6c9
--- /dev/null
+++ b/examples/preact/rick-morty/eslint.config.js
@@ -0,0 +1,20 @@
+// @ts-check
+
+import { tanstackConfig } from '@tanstack/eslint-config'
+import pluginQuery from '@tanstack/eslint-plugin-query'
+// @ts-ignore: no types for eslint-config-preact
+import preact from 'eslint-config-preact'
+import { defineConfig } from 'eslint/config'
+
+export default defineConfig([
+ ...preact,
+ ...tanstackConfig,
+ ...pluginQuery.configs['flat/recommended-strict'],
+ {
+ rules: {
+ 'no-duplicate-imports': 'off',
+ 'no-redeclare': 'off',
+ 'no-unused-vars': 'off',
+ },
+ },
+])
diff --git a/examples/preact/rick-morty/index.html b/examples/preact/rick-morty/index.html
new file mode 100644
index 0000000000..929fcb5efa
--- /dev/null
+++ b/examples/preact/rick-morty/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+ TanStack Query Preact Rick And Morty Example App
+
+
+ You need to enable JavaScript to run this app.
+
+
+
+
diff --git a/examples/preact/rick-morty/package.json b/examples/preact/rick-morty/package.json
new file mode 100644
index 0000000000..a65fedf52c
--- /dev/null
+++ b/examples/preact/rick-morty/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "@tanstack/query-example-preact-rick-morty",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "preview": "vite preview",
+ "test:eslint": "eslint ./src",
+ "test:types": "tsc --noEmit"
+ },
+ "dependencies": {
+ "@tanstack/preact-query": "^5.105.0",
+ "@tanstack/preact-query-devtools": "^5.105.0",
+ "preact": "^11.0.1",
+ "preact-iso": "^2.12.2"
+ },
+ "devDependencies": {
+ "@preact/preset-vite": "^2.10.6",
+ "@tailwindcss/vite": "^4.3.3",
+ "@tanstack/eslint-plugin-query": "^5.105.0",
+ "eslint": "^9.36.0",
+ "eslint-config-preact": "^2.0.0",
+ "tailwindcss": "^4.3.3",
+ "typescript": "^5.9.3",
+ "vite": "^8.3.1"
+ }
+}
diff --git a/examples/preact/rick-morty/public/emblem-light.svg b/examples/preact/rick-morty/public/emblem-light.svg
new file mode 100644
index 0000000000..a58e69ad5e
--- /dev/null
+++ b/examples/preact/rick-morty/public/emblem-light.svg
@@ -0,0 +1,13 @@
+
+
+
+ emblem-light
+ Created with Sketch.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/preact/rick-morty/src/App.tsx b/examples/preact/rick-morty/src/App.tsx
new file mode 100644
index 0000000000..a644c29cda
--- /dev/null
+++ b/examples/preact/rick-morty/src/App.tsx
@@ -0,0 +1,19 @@
+import { LocationProvider } from 'preact-iso'
+import { QueryClient, QueryClientProvider } from '@tanstack/preact-query'
+import { PreactQueryDevtools } from '@tanstack/preact-query-devtools'
+import Layout from './Layout'
+
+import './styles.css'
+
+const queryClient = new QueryClient()
+
+export default function App() {
+ return (
+
+
+
+
+
+
+ )
+}
diff --git a/examples/preact/rick-morty/src/Character.tsx b/examples/preact/rick-morty/src/Character.tsx
new file mode 100644
index 0000000000..ce47c0544e
--- /dev/null
+++ b/examples/preact/rick-morty/src/Character.tsx
@@ -0,0 +1,80 @@
+import { useRoute } from 'preact-iso'
+import { useQuery } from '@tanstack/preact-query'
+import { charactersQueries } from './services/characters/queries'
+import { episodesQueries } from './services/episodes/queries'
+import { locationsQueries } from './services/locations/queries'
+
+function Character() {
+ const { params } = useRoute()
+ const characterId = params.characterId
+
+ const { status, data } = useQuery(charactersQueries.detail(characterId))
+
+ if (status === 'pending') return Loading...
+ if (status === 'error') return Error :(
+
+ const locationUrlParts = data.location.url.split('/').filter(Boolean)
+ const locationId = locationUrlParts[locationUrlParts.length - 1]
+
+ return (
+
+
{data.name}
+
+ Gender : {data.gender}
+
+
+ Status : {data.status}
+
+
+ Species : {data.species}
+
+
+ Origin : {data.origin.name}
+
+
+ Location :
+
+
+
Episodes
+ {data.episode.map((episode) => {
+ const episodeUrlParts = episode.split('/').filter(Boolean)
+ const episodeId = episodeUrlParts[episodeUrlParts.length - 1]
+ return
+ })}
+
+ )
+}
+
+function Episode({ episodeId }: { episodeId: string }) {
+ const { data, status } = useQuery(episodesQueries.detail(episodeId))
+
+ if (status === 'success') {
+ return (
+
+
+
+ {data.episode}. {data.name} - {data.air_date}
+
+
+
+ )
+ }
+}
+
+function Location({ locationId }: { locationId: string }) {
+ const { data, status } = useQuery(locationsQueries.detail(locationId))
+
+ if (status === 'pending') return Loading...
+ if (status === 'error') return Error :(
+
+ return (
+
+ {data.name} - {data.type}
+
+ )
+}
+
+export default Character
diff --git a/examples/preact/rick-morty/src/Characters.tsx b/examples/preact/rick-morty/src/Characters.tsx
new file mode 100644
index 0000000000..b9832bab0f
--- /dev/null
+++ b/examples/preact/rick-morty/src/Characters.tsx
@@ -0,0 +1,29 @@
+import { useQuery } from '@tanstack/preact-query'
+import { charactersQueries } from './services/characters/queries'
+
+export default function Characters() {
+ const { status, data } = useQuery(charactersQueries.list())
+
+ if (status === 'pending') return Loading...
+ if (status === 'error') return Error :(
+
+ return (
+
+ )
+}
diff --git a/examples/preact/rick-morty/src/Episode.tsx b/examples/preact/rick-morty/src/Episode.tsx
new file mode 100644
index 0000000000..af2ec83df1
--- /dev/null
+++ b/examples/preact/rick-morty/src/Episode.tsx
@@ -0,0 +1,49 @@
+import { useRoute } from 'preact-iso'
+import { useQuery } from '@tanstack/preact-query'
+import { charactersQueries } from './services/characters/queries'
+import { episodesQueries } from './services/episodes/queries'
+
+function Episode() {
+ const { params } = useRoute()
+ const episodeId = params.episodeId
+
+ const { data, status } = useQuery(episodesQueries.detail(episodeId))
+
+ if (status === 'pending') return Loading...
+
+ if (status === 'error') return Error :(
+
+ return (
+
+
{data.name}
+
{data.air_date}
+
+
Characters
+ {data.characters.map((character) => {
+ const characterUrlParts = character.split('/').filter(Boolean)
+ const characterId = characterUrlParts[characterUrlParts.length - 1]
+ return
+ })}
+
+ )
+}
+
+function Character({ characterId }: { characterId: string }) {
+ const { data, status } = useQuery(charactersQueries.detail(characterId))
+
+ if (status === 'pending') return Loading...
+ if (status === 'error') return Error :(
+
+ return (
+
+
+ {data.name}
+
+
+ )
+}
+
+export default Episode
diff --git a/examples/preact/rick-morty/src/Episodes.tsx b/examples/preact/rick-morty/src/Episodes.tsx
new file mode 100644
index 0000000000..c170a03b6f
--- /dev/null
+++ b/examples/preact/rick-morty/src/Episodes.tsx
@@ -0,0 +1,31 @@
+import { useQuery } from '@tanstack/preact-query'
+import { episodesQueries } from './services/episodes/queries'
+
+export default function Episodes() {
+ const { data, status } = useQuery(episodesQueries.list())
+
+ if (status === 'pending') {
+ return Loading...
+ }
+ if (status === 'error') {
+ return Error :(
+ }
+
+ return (
+
+ )
+}
diff --git a/examples/preact/rick-morty/src/Home.tsx b/examples/preact/rick-morty/src/Home.tsx
new file mode 100644
index 0000000000..2129382157
--- /dev/null
+++ b/examples/preact/rick-morty/src/Home.tsx
@@ -0,0 +1,44 @@
+export default function Home() {
+ return (
+
+
TanStack Query Demo
+
Using the Rick And Morty API
+
+ (Built by{' '}
+
+ @axelfuh
+
+ )
+
+
Why TanStack Query?
+
+ In this demo you will be able to see how TanStack Query is a significant
+ improvement over redux , mobx , and any
+ other general-purpose state container.
+
+
+ No reducers, thunks, or sagas. No ES6 models to maintain in order to tag
+ them as observable.
+
+
+ Simply associate a key with your fetch call and let{' '}
+ TanStack Query handle the rest.
+
+
Ready to get started?
+
+ Check out the{' '}
+
+ Episodes
+ {' '}
+ and{' '}
+
+ Characters
+
+ !
+
+
+ )
+}
diff --git a/examples/preact/rick-morty/src/Layout.tsx b/examples/preact/rick-morty/src/Layout.tsx
new file mode 100644
index 0000000000..c98e2ba74b
--- /dev/null
+++ b/examples/preact/rick-morty/src/Layout.tsx
@@ -0,0 +1,33 @@
+import { Route, Router } from 'preact-iso'
+import Episodes from './Episodes'
+import Episode from './Episode'
+import Characters from './Characters'
+import Character from './Character'
+import Home from './Home'
+
+export default function Layout() {
+ return (
+
+ )
+}
diff --git a/examples/preact/rick-morty/src/index.tsx b/examples/preact/rick-morty/src/index.tsx
new file mode 100644
index 0000000000..83820d09f8
--- /dev/null
+++ b/examples/preact/rick-morty/src/index.tsx
@@ -0,0 +1,6 @@
+import { render } from 'preact'
+import App from './App'
+
+const rootElement = document.getElementById('root')
+if (!rootElement) throw new Error('Missing #root element')
+render( , rootElement)
diff --git a/examples/preact/rick-morty/src/services/characters/api.ts b/examples/preact/rick-morty/src/services/characters/api.ts
new file mode 100644
index 0000000000..d0b09a23f4
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/characters/api.ts
@@ -0,0 +1,16 @@
+import type { Character, Paginated } from './types'
+
+export const charactersAPI = {
+ getCharacters: async (): Promise> => {
+ const res = await fetch('https://rickandmortyapi.com/api/character/')
+ if (!res.ok) throw new Error('Failed to fetch characters')
+ return await res.json()
+ },
+ getCharacter: async (characterId: string): Promise => {
+ const res = await fetch(
+ `https://rickandmortyapi.com/api/character/${characterId}`,
+ )
+ if (!res.ok) throw new Error('Failed to fetch character')
+ return await res.json()
+ },
+}
diff --git a/examples/preact/rick-morty/src/services/characters/queries.ts b/examples/preact/rick-morty/src/services/characters/queries.ts
new file mode 100644
index 0000000000..3b9a715603
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/characters/queries.ts
@@ -0,0 +1,16 @@
+import { queryOptions } from '@tanstack/preact-query'
+import { charactersAPI } from './api'
+
+export const charactersQueries = {
+ all: () => ['characters'] as const,
+ list: () =>
+ queryOptions({
+ queryKey: [...charactersQueries.all(), 'list'] as const,
+ queryFn: () => charactersAPI.getCharacters(),
+ }),
+ detail: (characterId: string) =>
+ queryOptions({
+ queryKey: [...charactersQueries.all(), 'detail', characterId] as const,
+ queryFn: () => charactersAPI.getCharacter(characterId),
+ }),
+}
diff --git a/examples/preact/rick-morty/src/services/characters/types.ts b/examples/preact/rick-morty/src/services/characters/types.ts
new file mode 100644
index 0000000000..d9fd772eb6
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/characters/types.ts
@@ -0,0 +1,14 @@
+export type Character = {
+ id: number
+ name: string
+ status: string
+ species: string
+ gender: string
+ origin: { name: string; url: string }
+ location: { name: string; url: string }
+ episode: Array
+}
+
+export type Paginated = {
+ results: Array
+}
diff --git a/examples/preact/rick-morty/src/services/episodes/api.ts b/examples/preact/rick-morty/src/services/episodes/api.ts
new file mode 100644
index 0000000000..c71055be7b
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/episodes/api.ts
@@ -0,0 +1,16 @@
+import type { Episode, Paginated } from './types'
+
+export const episodesAPI = {
+ getEpisodes: async (): Promise> => {
+ const res = await fetch('https://rickandmortyapi.com/api/episode/')
+ if (!res.ok) throw new Error('Failed to fetch episodes')
+ return await res.json()
+ },
+ getEpisode: async (episodeId: string): Promise => {
+ const res = await fetch(
+ `https://rickandmortyapi.com/api/episode/${episodeId}`,
+ )
+ if (!res.ok) throw new Error('Failed to fetch episode')
+ return await res.json()
+ },
+}
diff --git a/examples/preact/rick-morty/src/services/episodes/queries.ts b/examples/preact/rick-morty/src/services/episodes/queries.ts
new file mode 100644
index 0000000000..6d55aeb4ee
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/episodes/queries.ts
@@ -0,0 +1,16 @@
+import { queryOptions } from '@tanstack/preact-query'
+import { episodesAPI } from './api'
+
+export const episodesQueries = {
+ all: () => ['episodes'] as const,
+ list: () =>
+ queryOptions({
+ queryKey: [...episodesQueries.all(), 'list'] as const,
+ queryFn: () => episodesAPI.getEpisodes(),
+ }),
+ detail: (episodeId: string) =>
+ queryOptions({
+ queryKey: [...episodesQueries.all(), 'detail', episodeId] as const,
+ queryFn: () => episodesAPI.getEpisode(episodeId),
+ }),
+}
diff --git a/examples/preact/rick-morty/src/services/episodes/types.ts b/examples/preact/rick-morty/src/services/episodes/types.ts
new file mode 100644
index 0000000000..15ab41cc73
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/episodes/types.ts
@@ -0,0 +1,11 @@
+export type Episode = {
+ id: number
+ name: string
+ air_date: string
+ episode: string
+ characters: Array
+}
+
+export type Paginated = {
+ results: Array
+}
diff --git a/examples/preact/rick-morty/src/services/locations/api.ts b/examples/preact/rick-morty/src/services/locations/api.ts
new file mode 100644
index 0000000000..ee9af2faae
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/locations/api.ts
@@ -0,0 +1,11 @@
+import type { Location } from './types'
+
+export const locationsAPI = {
+ getLocation: async (locationId: string): Promise => {
+ const res = await fetch(
+ `https://rickandmortyapi.com/api/location/${locationId}`,
+ )
+ if (!res.ok) throw new Error('Failed to fetch location')
+ return await res.json()
+ },
+}
diff --git a/examples/preact/rick-morty/src/services/locations/queries.ts b/examples/preact/rick-morty/src/services/locations/queries.ts
new file mode 100644
index 0000000000..069a45f6de
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/locations/queries.ts
@@ -0,0 +1,11 @@
+import { queryOptions } from '@tanstack/preact-query'
+import { locationsAPI } from './api'
+
+export const locationsQueries = {
+ all: () => ['locations'] as const,
+ detail: (locationId: string) =>
+ queryOptions({
+ queryKey: [...locationsQueries.all(), 'detail', locationId] as const,
+ queryFn: () => locationsAPI.getLocation(locationId),
+ }),
+}
diff --git a/examples/preact/rick-morty/src/services/locations/types.ts b/examples/preact/rick-morty/src/services/locations/types.ts
new file mode 100644
index 0000000000..8d4d1c1d79
--- /dev/null
+++ b/examples/preact/rick-morty/src/services/locations/types.ts
@@ -0,0 +1,5 @@
+export type Location = {
+ id: number
+ name: string
+ type: string
+}
diff --git a/examples/preact/rick-morty/src/styles.css b/examples/preact/rick-morty/src/styles.css
new file mode 100644
index 0000000000..b29ec798ac
--- /dev/null
+++ b/examples/preact/rick-morty/src/styles.css
@@ -0,0 +1,27 @@
+@import 'tailwindcss';
+
+@theme {
+ --font-sans:
+ Roboto, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Oxygen, Ubuntu,
+ Cantarell, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial,
+ sans-serif;
+ --font-mono:
+ Roboto Mono, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Oxygen,
+ Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial,
+ sans-serif;
+}
+
+@layer base {
+ body {
+ @apply font-sans;
+ }
+
+ h1,
+ h2,
+ h3,
+ h4,
+ h5,
+ h6 {
+ @apply font-mono;
+ }
+}
diff --git a/examples/preact/rick-morty/src/vite-env.d.ts b/examples/preact/rick-morty/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/examples/preact/rick-morty/src/vite-env.d.ts
@@ -0,0 +1 @@
+///
diff --git a/examples/preact/rick-morty/tsconfig.json b/examples/preact/rick-morty/tsconfig.json
new file mode 100644
index 0000000000..883cc3ab4f
--- /dev/null
+++ b/examples/preact/rick-morty/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+ "allowJs": true,
+ "checkJs": true,
+ "moduleResolution": "Bundler",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "react-jsx",
+ "jsxImportSource": "preact",
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["src", "eslint.config.js"]
+}
diff --git a/examples/preact/rick-morty/vite.config.ts b/examples/preact/rick-morty/vite.config.ts
new file mode 100644
index 0000000000..d55856bd40
--- /dev/null
+++ b/examples/preact/rick-morty/vite.config.ts
@@ -0,0 +1,7 @@
+import { defineConfig } from 'vite'
+import preact from '@preact/preset-vite'
+import tailwindcss from '@tailwindcss/vite'
+
+export default defineConfig({
+ plugins: [tailwindcss(), preact()],
+})
diff --git a/examples/preact/star-wars/.gitignore b/examples/preact/star-wars/.gitignore
new file mode 100644
index 0000000000..4673b022e5
--- /dev/null
+++ b/examples/preact/star-wars/.gitignore
@@ -0,0 +1,27 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# production
+/build
+
+pnpm-lock.yaml
+yarn.lock
+package-lock.json
+
+# misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
diff --git a/examples/preact/star-wars/README.md b/examples/preact/star-wars/README.md
new file mode 100644
index 0000000000..1cf8892652
--- /dev/null
+++ b/examples/preact/star-wars/README.md
@@ -0,0 +1,6 @@
+# Example
+
+To run this example:
+
+- `npm install`
+- `npm run dev`
diff --git a/examples/preact/star-wars/eslint.config.js b/examples/preact/star-wars/eslint.config.js
new file mode 100644
index 0000000000..b39d2be6c9
--- /dev/null
+++ b/examples/preact/star-wars/eslint.config.js
@@ -0,0 +1,20 @@
+// @ts-check
+
+import { tanstackConfig } from '@tanstack/eslint-config'
+import pluginQuery from '@tanstack/eslint-plugin-query'
+// @ts-ignore: no types for eslint-config-preact
+import preact from 'eslint-config-preact'
+import { defineConfig } from 'eslint/config'
+
+export default defineConfig([
+ ...preact,
+ ...tanstackConfig,
+ ...pluginQuery.configs['flat/recommended-strict'],
+ {
+ rules: {
+ 'no-duplicate-imports': 'off',
+ 'no-redeclare': 'off',
+ 'no-unused-vars': 'off',
+ },
+ },
+])
diff --git a/examples/preact/star-wars/index.html b/examples/preact/star-wars/index.html
new file mode 100644
index 0000000000..6718ad6cc2
--- /dev/null
+++ b/examples/preact/star-wars/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+ TanStack Query Preact Star Wars Example App
+
+
+ You need to enable JavaScript to run this app.
+
+
+
+
diff --git a/examples/preact/star-wars/package.json b/examples/preact/star-wars/package.json
new file mode 100644
index 0000000000..a89894ce0f
--- /dev/null
+++ b/examples/preact/star-wars/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "@tanstack/query-example-preact-star-wars",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "preview": "vite preview",
+ "test:eslint": "eslint ./src",
+ "test:types": "tsc --noEmit"
+ },
+ "dependencies": {
+ "@tanstack/preact-query": "^5.105.0",
+ "@tanstack/preact-query-devtools": "^5.105.0",
+ "preact": "^11.0.1",
+ "preact-iso": "^2.12.2"
+ },
+ "devDependencies": {
+ "@preact/preset-vite": "^2.10.6",
+ "@tailwindcss/vite": "^4.3.3",
+ "@tanstack/eslint-plugin-query": "^5.105.0",
+ "eslint": "^9.36.0",
+ "eslint-config-preact": "^2.0.0",
+ "tailwindcss": "^4.3.3",
+ "typescript": "^5.9.3",
+ "vite": "^8.3.1"
+ }
+}
diff --git a/examples/preact/star-wars/public/emblem-light.svg b/examples/preact/star-wars/public/emblem-light.svg
new file mode 100644
index 0000000000..a58e69ad5e
--- /dev/null
+++ b/examples/preact/star-wars/public/emblem-light.svg
@@ -0,0 +1,13 @@
+
+
+
+ emblem-light
+ Created with Sketch.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/preact/star-wars/src/App.tsx b/examples/preact/star-wars/src/App.tsx
new file mode 100644
index 0000000000..a644c29cda
--- /dev/null
+++ b/examples/preact/star-wars/src/App.tsx
@@ -0,0 +1,19 @@
+import { LocationProvider } from 'preact-iso'
+import { QueryClient, QueryClientProvider } from '@tanstack/preact-query'
+import { PreactQueryDevtools } from '@tanstack/preact-query-devtools'
+import Layout from './Layout'
+
+import './styles.css'
+
+const queryClient = new QueryClient()
+
+export default function App() {
+ return (
+
+
+
+
+
+
+ )
+}
diff --git a/examples/preact/star-wars/src/Character.tsx b/examples/preact/star-wars/src/Character.tsx
new file mode 100644
index 0000000000..f9596c56bb
--- /dev/null
+++ b/examples/preact/star-wars/src/Character.tsx
@@ -0,0 +1,72 @@
+import { useRoute } from 'preact-iso'
+import { useQuery } from '@tanstack/preact-query'
+import { filmsQueries } from './services/films/queries'
+import { charactersQueries } from './services/characters/queries'
+import { planetsQueries } from './services/planets/queries'
+
+export default function Character() {
+ const { params } = useRoute()
+ const characterId = params.characterId
+
+ const { status, data } = useQuery(charactersQueries.detail(characterId))
+
+ if (status === 'pending') return Loading...
+ if (status === 'error') return Error :(
+
+ const homeworldUrlParts = data.homeworld.split('/').filter(Boolean)
+ const homeworldId = homeworldUrlParts[homeworldUrlParts.length - 1]
+
+ return (
+
+
{data.name}
+
+ Born : {data.birth_year}
+
+
+ Eyes : {data.eye_color}
+
+
+ Hair : {data.hair_color}
+
+
+ Height : {data.height}
+
+
+ Mass : {data.mass}
+
+
+ Homeworld :
+
+
+
Films
+ {data.films.map((film) => {
+ const filmUrlParts = film.split('/').filter(Boolean)
+ const filmId = filmUrlParts[filmUrlParts.length - 1]
+ return
+ })}
+
+ )
+}
+
+function Film({ filmId }: { filmId: string }) {
+ const { data, status } = useQuery(filmsQueries.detail(filmId))
+
+ if (status === 'success') {
+ return (
+
+
+ {data.episode_id}. {data.title}
+
+
+ )
+ }
+}
+
+function Homeworld({ homeworldId }: { homeworldId: string }) {
+ const { data, status } = useQuery(planetsQueries.detail(homeworldId))
+
+ if (status === 'pending') return Loading...
+ if (status === 'error') return Error :(
+
+ return {data.name}
+}
diff --git a/examples/preact/star-wars/src/Characters.tsx b/examples/preact/star-wars/src/Characters.tsx
new file mode 100644
index 0000000000..caf8b13005
--- /dev/null
+++ b/examples/preact/star-wars/src/Characters.tsx
@@ -0,0 +1,29 @@
+import { useQuery } from '@tanstack/preact-query'
+import { charactersQueries } from './services/characters/queries'
+
+export default function Characters() {
+ const { status, data } = useQuery(charactersQueries.list())
+
+ if (status === 'pending') return Loading...
+ if (status === 'error') return Error :(
+
+ return (
+
+
Characters
+ {data.results.map((person) => {
+ const personUrlParts = person.url.split('/').filter(Boolean)
+ const personId = personUrlParts[personUrlParts.length - 1]
+ return (
+
+
+ {person.name}
+
+
+ )
+ })}
+
+ )
+}
diff --git a/examples/preact/star-wars/src/Film.tsx b/examples/preact/star-wars/src/Film.tsx
new file mode 100644
index 0000000000..73c06cce12
--- /dev/null
+++ b/examples/preact/star-wars/src/Film.tsx
@@ -0,0 +1,49 @@
+import { useRoute } from 'preact-iso'
+import { useQuery } from '@tanstack/preact-query'
+import { filmsQueries } from './services/films/queries'
+import { charactersQueries } from './services/characters/queries'
+
+export default function Film() {
+ const { filmId } = useRoute().params
+
+ const { data, status } = useQuery(filmsQueries.detail(filmId))
+
+ if (!filmId) {
+ return Invalid film ID
+ }
+
+ if (status === 'pending') return Loading...
+
+ if (status === 'error') return Error :(
+
+ return (
+
+
{data.title}
+
{data.opening_crawl}
+
+
Characters
+ {data.characters.map((character) => {
+ const characterUrlParts = character.split('/').filter(Boolean)
+ const characterId = characterUrlParts[characterUrlParts.length - 1]
+ return
+ })}
+
+ )
+}
+
+function Character({ characterId }: { characterId: string }) {
+ const { data, status } = useQuery(charactersQueries.detail(characterId))
+
+ if (status !== 'success') {
+ return null
+ }
+
+ return (
+
+ {data.name}
+
+ )
+}
diff --git a/examples/preact/star-wars/src/Films.tsx b/examples/preact/star-wars/src/Films.tsx
new file mode 100644
index 0000000000..1cf8c88a53
--- /dev/null
+++ b/examples/preact/star-wars/src/Films.tsx
@@ -0,0 +1,38 @@
+import { useQuery } from '@tanstack/preact-query'
+import { filmsQueries } from './services/films/queries'
+
+export default function Films() {
+ const { data, status } = useQuery(filmsQueries.list())
+
+ if (status === 'pending') {
+ return Loading...
+ }
+ if (status === 'error') {
+ return Error :(
+ }
+
+ return (
+
+ )
+}
diff --git a/examples/preact/star-wars/src/Home.tsx b/examples/preact/star-wars/src/Home.tsx
new file mode 100644
index 0000000000..ca96213e37
--- /dev/null
+++ b/examples/preact/star-wars/src/Home.tsx
@@ -0,0 +1,44 @@
+export default function Home() {
+ return (
+
+
TanStack Query Demo
+
Using the Star Wars API
+
+ (Built by{' '}
+
+ @Brent_m_Clark
+
+ )
+
+
Why TanStack Query?
+
+ In this demo you will be able to see how TanStack Query is a significant
+ improvement over redux , mobx , and any
+ other general-purpose state container.
+
+
+ No reducers, thunks, or sagas. No ES6 models to maintain in order to tag
+ them as observable.
+
+
+ Simply associate a key with your fetch call and let{' '}
+ TanStack Query handle the rest.
+
+
Ready to get started?
+
+ Check out the{' '}
+
+ Films
+ {' '}
+ and{' '}
+
+ Characters
+
+ !
+
+
+ )
+}
diff --git a/examples/preact/star-wars/src/Layout.tsx b/examples/preact/star-wars/src/Layout.tsx
new file mode 100644
index 0000000000..fbaf2373a2
--- /dev/null
+++ b/examples/preact/star-wars/src/Layout.tsx
@@ -0,0 +1,33 @@
+import { Route, Router } from 'preact-iso'
+import Films from './Films'
+import Film from './Film'
+import Characters from './Characters'
+import Character from './Character'
+import Home from './Home'
+
+export default function Layout() {
+ return (
+
+ )
+}
diff --git a/examples/preact/star-wars/src/index.tsx b/examples/preact/star-wars/src/index.tsx
new file mode 100644
index 0000000000..83820d09f8
--- /dev/null
+++ b/examples/preact/star-wars/src/index.tsx
@@ -0,0 +1,6 @@
+import { render } from 'preact'
+import App from './App'
+
+const rootElement = document.getElementById('root')
+if (!rootElement) throw new Error('Missing #root element')
+render( , rootElement)
diff --git a/examples/preact/star-wars/src/services/characters/api.ts b/examples/preact/star-wars/src/services/characters/api.ts
new file mode 100644
index 0000000000..da5bc700b3
--- /dev/null
+++ b/examples/preact/star-wars/src/services/characters/api.ts
@@ -0,0 +1,14 @@
+import type { Character, Paginated } from './types'
+
+export const charactersAPI = {
+ getCharacters: async (): Promise> => {
+ const res = await fetch('https://swapi.dev/api/people/')
+ if (!res.ok) throw new Error('Failed to fetch characters')
+ return await res.json()
+ },
+ getCharacter: async (characterId: string): Promise => {
+ const res = await fetch(`https://swapi.dev/api/people/${characterId}/`)
+ if (!res.ok) throw new Error('Failed to fetch character')
+ return await res.json()
+ },
+}
diff --git a/examples/preact/star-wars/src/services/characters/queries.ts b/examples/preact/star-wars/src/services/characters/queries.ts
new file mode 100644
index 0000000000..3b9a715603
--- /dev/null
+++ b/examples/preact/star-wars/src/services/characters/queries.ts
@@ -0,0 +1,16 @@
+import { queryOptions } from '@tanstack/preact-query'
+import { charactersAPI } from './api'
+
+export const charactersQueries = {
+ all: () => ['characters'] as const,
+ list: () =>
+ queryOptions({
+ queryKey: [...charactersQueries.all(), 'list'] as const,
+ queryFn: () => charactersAPI.getCharacters(),
+ }),
+ detail: (characterId: string) =>
+ queryOptions({
+ queryKey: [...charactersQueries.all(), 'detail', characterId] as const,
+ queryFn: () => charactersAPI.getCharacter(characterId),
+ }),
+}
diff --git a/examples/preact/star-wars/src/services/characters/types.ts b/examples/preact/star-wars/src/services/characters/types.ts
new file mode 100644
index 0000000000..29c8fd3a72
--- /dev/null
+++ b/examples/preact/star-wars/src/services/characters/types.ts
@@ -0,0 +1,15 @@
+export type Character = {
+ name: string
+ height: string
+ mass: string
+ hair_color: string
+ eye_color: string
+ birth_year: string
+ homeworld: string
+ films: Array
+ url: string
+}
+
+export type Paginated = {
+ results: Array
+}
diff --git a/examples/preact/star-wars/src/services/films/api.ts b/examples/preact/star-wars/src/services/films/api.ts
new file mode 100644
index 0000000000..68825ffac6
--- /dev/null
+++ b/examples/preact/star-wars/src/services/films/api.ts
@@ -0,0 +1,14 @@
+import type { Film, Paginated } from './types'
+
+export const filmsAPI = {
+ getFilms: async (): Promise> => {
+ const res = await fetch('https://swapi.dev/api/films/')
+ if (!res.ok) throw new Error('Failed to fetch films')
+ return await res.json()
+ },
+ getFilm: async (filmId: string): Promise => {
+ const res = await fetch(`https://swapi.dev/api/films/${filmId}/`)
+ if (!res.ok) throw new Error('Failed to fetch film')
+ return await res.json()
+ },
+}
diff --git a/examples/preact/star-wars/src/services/films/queries.ts b/examples/preact/star-wars/src/services/films/queries.ts
new file mode 100644
index 0000000000..222480dc4c
--- /dev/null
+++ b/examples/preact/star-wars/src/services/films/queries.ts
@@ -0,0 +1,16 @@
+import { queryOptions, skipToken } from '@tanstack/preact-query'
+import { filmsAPI } from './api'
+
+export const filmsQueries = {
+ all: () => ['films'] as const,
+ list: () =>
+ queryOptions({
+ queryKey: [...filmsQueries.all(), 'list'] as const,
+ queryFn: () => filmsAPI.getFilms(),
+ }),
+ detail: (filmId: string | undefined) =>
+ queryOptions({
+ queryKey: [...filmsQueries.all(), 'detail', filmId] as const,
+ queryFn: filmId ? () => filmsAPI.getFilm(filmId) : skipToken,
+ }),
+}
diff --git a/examples/preact/star-wars/src/services/films/types.ts b/examples/preact/star-wars/src/services/films/types.ts
new file mode 100644
index 0000000000..4fd79e4f5e
--- /dev/null
+++ b/examples/preact/star-wars/src/services/films/types.ts
@@ -0,0 +1,12 @@
+export type Film = {
+ title: string
+ episode_id: number
+ opening_crawl: string
+ release_date: string
+ characters: Array
+ url: string
+}
+
+export type Paginated = {
+ results: Array
+}
diff --git a/examples/preact/star-wars/src/services/planets/api.ts b/examples/preact/star-wars/src/services/planets/api.ts
new file mode 100644
index 0000000000..d169103e93
--- /dev/null
+++ b/examples/preact/star-wars/src/services/planets/api.ts
@@ -0,0 +1,9 @@
+import type { Planet } from './types'
+
+export const planetsAPI = {
+ getPlanet: async (planetId: string): Promise => {
+ const res = await fetch(`https://swapi.dev/api/planets/${planetId}/`)
+ if (!res.ok) throw new Error('Failed to fetch planet')
+ return await res.json()
+ },
+}
diff --git a/examples/preact/star-wars/src/services/planets/queries.ts b/examples/preact/star-wars/src/services/planets/queries.ts
new file mode 100644
index 0000000000..c4fe09896b
--- /dev/null
+++ b/examples/preact/star-wars/src/services/planets/queries.ts
@@ -0,0 +1,11 @@
+import { queryOptions } from '@tanstack/preact-query'
+import { planetsAPI } from './api'
+
+export const planetsQueries = {
+ all: () => ['planets'] as const,
+ detail: (planetId: string) =>
+ queryOptions({
+ queryKey: [...planetsQueries.all(), 'detail', planetId] as const,
+ queryFn: () => planetsAPI.getPlanet(planetId),
+ }),
+}
diff --git a/examples/preact/star-wars/src/services/planets/types.ts b/examples/preact/star-wars/src/services/planets/types.ts
new file mode 100644
index 0000000000..50bc6c8dab
--- /dev/null
+++ b/examples/preact/star-wars/src/services/planets/types.ts
@@ -0,0 +1,3 @@
+export type Planet = {
+ name: string
+}
diff --git a/examples/preact/star-wars/src/styles.css b/examples/preact/star-wars/src/styles.css
new file mode 100644
index 0000000000..b29ec798ac
--- /dev/null
+++ b/examples/preact/star-wars/src/styles.css
@@ -0,0 +1,27 @@
+@import 'tailwindcss';
+
+@theme {
+ --font-sans:
+ Roboto, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Oxygen, Ubuntu,
+ Cantarell, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial,
+ sans-serif;
+ --font-mono:
+ Roboto Mono, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Oxygen,
+ Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial,
+ sans-serif;
+}
+
+@layer base {
+ body {
+ @apply font-sans;
+ }
+
+ h1,
+ h2,
+ h3,
+ h4,
+ h5,
+ h6 {
+ @apply font-mono;
+ }
+}
diff --git a/examples/preact/star-wars/src/vite-env.d.ts b/examples/preact/star-wars/src/vite-env.d.ts
new file mode 100644
index 0000000000..11f02fe2a0
--- /dev/null
+++ b/examples/preact/star-wars/src/vite-env.d.ts
@@ -0,0 +1 @@
+///
diff --git a/examples/preact/star-wars/tsconfig.json b/examples/preact/star-wars/tsconfig.json
new file mode 100644
index 0000000000..883cc3ab4f
--- /dev/null
+++ b/examples/preact/star-wars/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+ "allowJs": true,
+ "checkJs": true,
+ "moduleResolution": "Bundler",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "react-jsx",
+ "jsxImportSource": "preact",
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "include": ["src", "eslint.config.js"]
+}
diff --git a/examples/preact/star-wars/vite.config.ts b/examples/preact/star-wars/vite.config.ts
new file mode 100644
index 0000000000..d55856bd40
--- /dev/null
+++ b/examples/preact/star-wars/vite.config.ts
@@ -0,0 +1,7 @@
+import { defineConfig } from 'vite'
+import preact from '@preact/preset-vite'
+import tailwindcss from '@tailwindcss/vite'
+
+export default defineConfig({
+ plugins: [tailwindcss(), preact()],
+})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 331394a387..d467322665 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1166,6 +1166,55 @@ importers:
specifier: ^8.3.1
version: 8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1)
+ examples/preact/offline:
+ dependencies:
+ '@tanstack/preact-query':
+ specifier: ^5.105.0
+ version: link:../../../packages/preact-query
+ '@tanstack/preact-query-devtools':
+ specifier: ^5.105.0
+ version: link:../../../packages/preact-query-devtools
+ '@tanstack/preact-query-persist-client':
+ specifier: ^5.105.0
+ version: link:../../../packages/preact-query-persist-client
+ '@tanstack/query-async-storage-persister':
+ specifier: ^5.105.0
+ version: link:../../../packages/query-async-storage-persister
+ '@zag-js/preact':
+ specifier: ^1.46.0
+ version: 1.46.0(preact@11.0.1)
+ '@zag-js/toast':
+ specifier: ^1.46.0
+ version: 1.46.0
+ msw:
+ specifier: ^2.15.0
+ version: 2.15.0(@types/node@24.19.2)(typescript@5.9.3)
+ preact:
+ specifier: ^11.0.1
+ version: 11.0.1(preact-render-to-string@6.8.0)
+ preact-iso:
+ specifier: ^2.12.2
+ version: 2.12.2(preact-render-to-string@6.8.0)(preact@11.0.1)
+ devDependencies:
+ '@preact/preset-vite':
+ specifier: ^2.10.6
+ version: 2.10.6(@babel/core@7.29.7(supports-color@10.2.2))(preact@11.0.1)(rollup@4.60.1)(supports-color@10.2.2)(vite@8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1))
+ '@tanstack/eslint-plugin-query':
+ specifier: ^5.105.0
+ version: link:../../../packages/eslint-plugin-query
+ eslint:
+ specifier: ^9.36.0
+ version: 9.39.4(jiti@2.7.0)(supports-color@10.2.2)
+ eslint-config-preact:
+ specifier: ^2.0.0
+ version: 2.0.0(eslint@9.39.4(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)
+ typescript:
+ specifier: ^5.9.3
+ version: 5.9.3
+ vite:
+ specifier: ^8.3.1
+ version: 8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1)
+
examples/preact/playground:
dependencies:
'@tanstack/preact-query':
@@ -1197,6 +1246,46 @@ importers:
specifier: ^8.3.1
version: 8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1)
+ examples/preact/rick-morty:
+ dependencies:
+ '@tanstack/preact-query':
+ specifier: ^5.105.0
+ version: link:../../../packages/preact-query
+ '@tanstack/preact-query-devtools':
+ specifier: ^5.105.0
+ version: link:../../../packages/preact-query-devtools
+ preact:
+ specifier: ^11.0.1
+ version: 11.0.1(preact-render-to-string@6.8.0)
+ preact-iso:
+ specifier: ^2.12.2
+ version: 2.12.2(preact-render-to-string@6.8.0)(preact@11.0.1)
+ devDependencies:
+ '@preact/preset-vite':
+ specifier: ^2.10.6
+ version: 2.10.6(@babel/core@7.29.7(supports-color@10.2.2))(preact@11.0.1)(rollup@4.60.1)(supports-color@10.2.2)(vite@8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1))
+ '@tailwindcss/vite':
+ specifier: ^4.3.3
+ version: 4.3.3(vite@8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1))
+ '@tanstack/eslint-plugin-query':
+ specifier: ^5.105.0
+ version: link:../../../packages/eslint-plugin-query
+ eslint:
+ specifier: ^9.36.0
+ version: 9.39.4(jiti@2.7.0)(supports-color@10.2.2)
+ eslint-config-preact:
+ specifier: ^2.0.0
+ version: 2.0.0(eslint@9.39.4(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)
+ tailwindcss:
+ specifier: ^4.3.3
+ version: 4.3.3
+ typescript:
+ specifier: ^5.9.3
+ version: 5.9.3
+ vite:
+ specifier: ^8.3.1
+ version: 8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1)
+
examples/preact/shadow-dom:
dependencies:
'@tanstack/preact-query':
@@ -1256,6 +1345,46 @@ importers:
specifier: ^8.3.1
version: 8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.0)
+ examples/preact/star-wars:
+ dependencies:
+ '@tanstack/preact-query':
+ specifier: ^5.105.0
+ version: link:../../../packages/preact-query
+ '@tanstack/preact-query-devtools':
+ specifier: ^5.105.0
+ version: link:../../../packages/preact-query-devtools
+ preact:
+ specifier: ^11.0.1
+ version: 11.0.1(preact-render-to-string@6.8.0)
+ preact-iso:
+ specifier: ^2.12.2
+ version: 2.12.2(preact-render-to-string@6.8.0)(preact@11.0.1)
+ devDependencies:
+ '@preact/preset-vite':
+ specifier: ^2.10.6
+ version: 2.10.6(@babel/core@7.29.7(supports-color@10.2.2))(preact@11.0.1)(rollup@4.60.1)(supports-color@10.2.2)(vite@8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1))
+ '@tailwindcss/vite':
+ specifier: ^4.3.3
+ version: 4.3.3(vite@8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1))
+ '@tanstack/eslint-plugin-query':
+ specifier: ^5.105.0
+ version: link:../../../packages/eslint-plugin-query
+ eslint:
+ specifier: ^9.36.0
+ version: 9.39.4(jiti@2.7.0)(supports-color@10.2.2)
+ eslint-config-preact:
+ specifier: ^2.0.0
+ version: 2.0.0(eslint@9.39.4(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)
+ tailwindcss:
+ specifier: ^4.3.3
+ version: 4.3.3
+ typescript:
+ specifier: ^5.9.3
+ version: 5.9.3
+ vite:
+ specifier: ^8.3.1
+ version: 8.3.1(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.90.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.9.1)
+
examples/react/algolia:
dependencies:
'@algolia/client-search':
@@ -10650,6 +10779,38 @@ packages:
'@yuku-toolchain/types@0.10.2':
resolution: {integrity: sha512-sSeo4SSSToiS+sSD+bwn/s94EEcaLJ7tG5LCp8gFYC1G5VzxzX7fqB6m9RU1yMD8KTpu6zdU/I1NlQf8hVBJ9Q==}
+ '@zag-js/anatomy@1.46.0':
+ resolution: {integrity: sha512-geWPKs9FtZ3FihwOyW/swG3IlJxqGydiAEUHRjBq3q45IarxV4gJZfpvWGlv20mVjOhbWkNEG+CDPsUGw4ixow==}
+
+ '@zag-js/core@1.46.0':
+ resolution: {integrity: sha512-zwiTDz9iBi1a/CyzdaeI8TlBADmeLCDNONh930a7x32TpduN8LiY26X58zrgimvCowOu7YIFNzI/vqW7Wp1phA==}
+
+ '@zag-js/dismissable@1.46.0':
+ resolution: {integrity: sha512-HramN58RwrpuSEdrN7XecL7g5wvwck3HJE81s7zli2qP/kIaVLodE5qbzR/PW4715daM1rO+Ptsd96dkeBzICQ==}
+
+ '@zag-js/dom-query@1.46.0':
+ resolution: {integrity: sha512-ibkO0VkQ2rLaclrO/O7kunvvwK8ZiW2L78arxsPYOEWmTqdNM6eQh721l9jGREUggh8nGsydNaoJH7lP3z1DUg==}
+
+ '@zag-js/interact-outside@1.46.0':
+ resolution: {integrity: sha512-gzOj8zNvZzrF8l7ikYcYmdOlhLXEBGm7Qsp++hE/in47Nhi1uHWlamW21orqYdNF8Y250qrK24vIr0ZW4xTPcw==}
+
+ '@zag-js/preact@1.46.0':
+ resolution: {integrity: sha512-o6jxX06Gz6ZNzVlVGN6PW3zw7PxTryHDs/JNg7lKVMV9h0fNH6C0pRkTP0AK8as0VSVjpH+EycxkNyfrwat2ag==}
+ peerDependencies:
+ preact: '>=10.0.0'
+
+ '@zag-js/store@1.46.0':
+ resolution: {integrity: sha512-NXjE6pITQaORVDxSX5nriNMtIBJGpq92ni3YvcZ1f37CZO2qXumOnYzyWWJNSwDMpfqEmPh83cW0Nxse7AUILA==}
+
+ '@zag-js/toast@1.46.0':
+ resolution: {integrity: sha512-7EL8nm6Z1P64XEUqHT3DPHKi/F+0UR9fJeL6ELgnqpDMYwOPNCxTXnh26vIV0g9UWyorMdgZMqljAchMPF5xMQ==}
+
+ '@zag-js/types@1.46.0':
+ resolution: {integrity: sha512-HwIvuXCGx/wgCNNXYvKyCJ62e/QmIi02v9GsA0icFxDKxv6i7J2mZmAQ/vF5Nmh3q80Nj5CZ1DdQ7bXYt/Yzww==}
+
+ '@zag-js/utils@1.46.0':
+ resolution: {integrity: sha512-SOKa832hWCoXaYB2Pcdb0c+ZcyNSuAAPpL5YRnVHskuc0BEsHPWOhxSIxuGF1gvz4RsfBKiAHrDoFDl8JLSOEg==}
+
'@zkochan/js-yaml@0.0.7':
resolution: {integrity: sha512-nrUSn7hzt7J6JWgWGz78ZYI8wj+gdIJdk0Ynjpp8l+trkn58Uqsf6RYrYkEK+3X18EX+TNdtJI0WxAtc+L84SQ==}
hasBin: true
@@ -15749,6 +15910,12 @@ packages:
resolution: {integrity: sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==}
engines: {node: '>=20'}
+ preact-iso@2.12.2:
+ resolution: {integrity: sha512-qit+qSMiZ41K0EQkLNa3MSxnWVCm5yXvy9m3CcGf/zF1QhVJzSwVCbpiz52VSbWpg8v8nYNIYDrXJZPNFpM1uw==}
+ peerDependencies:
+ preact: '>=10 || >= 11.0.0-0'
+ preact-render-to-string: '>=6.4.0'
+
preact-render-to-string@6.8.0:
resolution: {integrity: sha512-2qiMrReQz+MZ5+/bT27kbVnFE7QNCC2fku/Tnc2H5bFUS3I3ASbRy0q72XLZ+2p2KyDE5xMfvSEtkmVo6TRNyA==}
peerDependencies:
@@ -15866,6 +16033,9 @@ packages:
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
engines: {node: '>= 0.10'}
+ proxy-compare@3.0.1:
+ resolution: {integrity: sha512-V9plBAt3qjMlS1+nC8771KNf6oJ12gExvaxnNzN/9yVRLdTv/lc+oJlnSzrdYDAvBfTStPCoiaCOTmTs0adv7Q==}
+
proxy-from-env@2.1.0:
resolution: {integrity: sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==}
engines: {node: '>=10'}
@@ -25929,6 +26099,55 @@ snapshots:
'@yuku-toolchain/types@0.10.2': {}
+ '@zag-js/anatomy@1.46.0': {}
+
+ '@zag-js/core@1.46.0':
+ dependencies:
+ '@zag-js/dom-query': 1.46.0
+ '@zag-js/utils': 1.46.0
+
+ '@zag-js/dismissable@1.46.0':
+ dependencies:
+ '@zag-js/dom-query': 1.46.0
+ '@zag-js/interact-outside': 1.46.0
+ '@zag-js/utils': 1.46.0
+
+ '@zag-js/dom-query@1.46.0':
+ dependencies:
+ '@zag-js/types': 1.46.0
+
+ '@zag-js/interact-outside@1.46.0':
+ dependencies:
+ '@zag-js/dom-query': 1.46.0
+ '@zag-js/utils': 1.46.0
+
+ '@zag-js/preact@1.46.0(preact@11.0.1)':
+ dependencies:
+ '@zag-js/core': 1.46.0
+ '@zag-js/store': 1.46.0
+ '@zag-js/types': 1.46.0
+ '@zag-js/utils': 1.46.0
+ preact: 11.0.1(preact-render-to-string@6.8.0)
+
+ '@zag-js/store@1.46.0':
+ dependencies:
+ proxy-compare: 3.0.1
+
+ '@zag-js/toast@1.46.0':
+ dependencies:
+ '@zag-js/anatomy': 1.46.0
+ '@zag-js/core': 1.46.0
+ '@zag-js/dismissable': 1.46.0
+ '@zag-js/dom-query': 1.46.0
+ '@zag-js/types': 1.46.0
+ '@zag-js/utils': 1.46.0
+
+ '@zag-js/types@1.46.0':
+ dependencies:
+ csstype: 3.2.3
+
+ '@zag-js/utils@1.46.0': {}
+
'@zkochan/js-yaml@0.0.7':
dependencies:
argparse: 2.0.1
@@ -31465,6 +31684,31 @@ snapshots:
transitivePeerDependencies:
- '@types/node'
+ msw@2.15.0(@types/node@24.19.2)(typescript@5.9.3):
+ dependencies:
+ '@inquirer/confirm': 6.3.2(@types/node@24.19.2)
+ '@mswjs/interceptors': 0.41.3
+ '@open-draft/deferred-promise': 3.0.0
+ '@types/statuses': 2.0.6
+ cookie: 1.1.1
+ graphql: 16.13.2
+ headers-polyfill: 5.0.1
+ is-node-process: 1.2.0
+ outvariant: 1.4.3
+ path-to-regexp: 6.3.0
+ picocolors: 1.1.1
+ rettime: 0.11.11
+ statuses: 2.0.2
+ strict-event-emitter: 0.5.1
+ tough-cookie: 6.0.1
+ type-fest: 5.5.0
+ until-async: 3.0.2
+ yargs: 17.7.2
+ optionalDependencies:
+ typescript: 5.9.3
+ transitivePeerDependencies:
+ - '@types/node'
+
msw@2.15.0(@types/node@24.19.2)(typescript@6.0.3):
dependencies:
'@inquirer/confirm': 6.3.2(@types/node@24.19.2)
@@ -32784,6 +33028,11 @@ snapshots:
powershell-utils@0.1.0: {}
+ preact-iso@2.12.2(preact-render-to-string@6.8.0)(preact@11.0.1):
+ dependencies:
+ preact: 11.0.1(preact-render-to-string@6.8.0)
+ preact-render-to-string: 6.8.0(preact@11.0.1)
+
preact-render-to-string@6.8.0(preact@11.0.1):
dependencies:
preact: 11.0.1(preact-render-to-string@6.8.0)
@@ -32882,6 +33131,8 @@ snapshots:
forwarded: 0.2.0
ipaddr.js: 1.9.1
+ proxy-compare@3.0.1: {}
+
proxy-from-env@2.1.0: {}
prr@1.0.1: {}