From floating-ui-vue
Provides API reference, breaking changes, new features, and migration guides for TanStack Vue Query v5. Use when importing '@tanstack/vue-query' for data management, caching, and debugging.
npx claudepluginhub skilld-dev/vue-ecosystem-skills --plugin floating-ui-vueThis skill uses the workspace's default tool permissions.
**Tags:** alpha: 5.0.0-alpha.91, beta: 5.0.0-beta.35, rc: 5.0.0-rc.16
references/discussions/_INDEX.mdreferences/discussions/discussion-10009.mdreferences/discussions/discussion-10021.mdreferences/discussions/discussion-10027.mdreferences/discussions/discussion-10062.mdreferences/discussions/discussion-10068.mdreferences/discussions/discussion-10070.mdreferences/discussions/discussion-10097.mdreferences/discussions/discussion-10130.mdreferences/discussions/discussion-10136.mdreferences/discussions/discussion-9857.mdreferences/discussions/discussion-9860.mdreferences/discussions/discussion-9861.mdreferences/discussions/discussion-9863.mdreferences/discussions/discussion-9869.mdreferences/discussions/discussion-9899.mdreferences/discussions/discussion-9903.mdreferences/discussions/discussion-9912.mdreferences/discussions/discussion-9948.mdreferences/discussions/discussion-9957.mdGuides TanStack Query v5 (React Query) for React server state management: data fetching, caching, mutations, v4 migrations, stale data, invalidation, and optimistic updates.
Optimizes TanStack Query v5 performance with 40 rules across query keys, caching, mutations, prefetching, infinite queries, Suspense, errors, and rendering.
Implements TanStack Query v5 in React apps for API data fetching, server state caching, mutations, optimistic updates, infinite scroll, streaming AI responses, and tRPC v11 integration.
Share bugs, ideas, or general feedback.
@tanstack/vue-query@5.96.2Tags: alpha: 5.0.0-alpha.91, beta: 5.0.0-beta.35, rc: 5.0.0-rc.16
References: Docs
This section documents version-specific API changes — prioritize recent major/minor releases.
BREAKING: useQuery signature — v5 requires a single object argument { queryKey, queryFn, ... }. Old positional arguments are no longer supported and will result in errors source
BREAKING: useQueries signature — v5 now takes an object with a queries array property: useQueries({ queries: [...] }). This allows for additional top-level options like combine
BREAKING: useQueries return type — now returns a Ref of the results array instead of a reactive array, ensuring better compatibility with Vue 2 and avoiding spread reactivity loss source
BREAKING: Callback removal — onSuccess, onError, and onSettled are removed from useQuery, useInfiniteQuery, and useQueries. Use select for data transformation or global QueryCache callbacks instead source
BREAKING: cacheTime renamed — renamed to gcTime (Garbage Collection time) across all options and default options to better reflect its purpose source
BREAKING: useInfiniteQuery parameters — getNextPageParam and getPreviousPageParam now receive a single object containing lastPage, allPages, lastPageParam, and allPageParams source
BREAKING: keepPreviousData removed — the option is replaced by the placeholderData: keepPreviousData helper function from @tanstack/vue-query source
NEW: queryOptions / infiniteQueryOptions — helper functions for sharing query definitions with type safety across components and for prefetching source
NEW: useMutationState — new composable to access mutation state globally by filtering for specific mutations based on keys or filters
NEW: Options Getter support — useQuery and useInfiniteQuery now support passing a getter function (e.g., () => options) or a Ref for the entire options object, enabling easier reactivity
NEW: combine for useQueries — allows merging multiple query results into a single value (e.g., a single object or a derived state) via the combine option
NEW: Injection Context — vue-query composables can now be used in any function that supports injectionContext (e.g., router guards) if used within an effectScope source
DEPRECATED: isLoading — renamed to isPending in v5. The isLoading property now specifically means isPending && isFetching (fetching for the first time) source
BREAKING: Vue 3.3 requirement — minimum Vue version for @tanstack/vue-query v5 is now 3.3 to support newer reactivity features source
Also changed: isPlaceholderData boolean result new v5 · initialPageParam required for useInfiniteQuery · isPaused property added to query results · Suspense (experimental) supported via suspense() method (experimental)
MaybeRefOrGetter for composable parameters to support refs, plain values, and reactive getters seamlessly source// Preferred: Accepts ref, getter, or value
export function useUser(id: MaybeRefOrGetter<string>) {
return useQuery({
queryKey: ['user', id],
queryFn: () => fetchUser(toValue(id))
})
}
// Preferred for complex reactivity
useQuery(() => ({
queryKey: ['todo', id.value],
queryFn: () => fetchTodo(id.value),
enabled: !!id.value
}))
computed for simple property access to avoid unnecessary memoization overhead source// Preferred: No computed needed
const { data } = useUserProjects(() => props.userId)
// Avoid: Unnecessary memoization
const userId = computed(() => props.userId)
const { data } = useUserProjects(userId)
onServerPrefetch with the suspense() helper to ensure queries are awaited during SSR sourceconst { data, suspense } = useQuery({ queryKey: ['test'], queryFn: fetcher })
onServerPrefetch(suspense)
staleTime to a value greater than 0 for SSR to prevent immediate background refetching on the client sourceconst queryClient = new QueryClient({
defaultOptions: { queries: { staleTime: 1000 * 60 * 5 } }
})
Manually call queryClient.clear() after request handling if gcTime is set to a non-Infinity value on the server to prevent memory leaks source
Treat useQuery results as immutable and clone data before using it with two-way bindings like v-model source
const { data } = useQuery({ ... })
const model = ref()
watch(data, (newData) => {
model.value = JSON.parse(JSON.stringify(newData))
}, { immediate: true })
queryOptions helper to define type-safe, reusable query configurations that can be shared across componentsconst userOptions = (id: string) => queryOptions({
queryKey: ['user', id],
queryFn: () => fetchUser(id)
})
useQuery(userOptions('123'))
Include all reactive dependencies in the queryKey to ensure Vue Query tracks them and refetches automatically on change source
Utilize a custom queryClientKey when running multiple Vue applications on the same page to prevent QueryClient instance clashing source
// Plugin configuration
app.use(VueQueryPlugin, { queryClientKey: 'AppA' })
// Usage
useQuery({ queryKey: ['data'], queryFn: fetcher, queryClientKey: 'AppA' })