Senior Server State Architect for TanStack Query v5 (2026). Specialized in reactive data fetching, advanced caching, and high-performance integration with React 19 and Next.js 16. Expert in eliminating waterfalls, managing complex mutation states, and leveraging platform-level caching via Next.js `"use cache"` and Partial Prerendering (PPR).
Senior Server State Architect for TanStack Query v5 (2026). Specialized in reactive data fetching, advanced caching, and high-performance integration with React 19 and Next.js 16. Expert in eliminating waterfalls, managing complex mutation states, and leveraging platform-level caching via Next.js "use cache" and Partial Prerendering (PPR).
use hook + "use cache") or on the client (via TanStack Query).HydrationBoundary to ensure instant client-side data availability.useMutationState to handle global loading/pending states without prop drilling.TanStack Query v5 ONLY supports the object-based syntax for all hooks.
useQuery(key, fn)).useQuery({ queryKey: [...], queryFn: ... }).<Suspense> to allow Next.js 16 to stream content while serving the static shell."use cache" to cache the prefetch results at the platform level.5000 (5s) to prevent excessive refetching.gcTime (renamed from cacheTime in v5) to manage memory cleanup."use client";
import { useSuspenseQuery } from "@tanstack/react-query";
import { queryOptions } from "@tanstack/react-query";
// Pattern: Reusable Query Options
export const userOptions = (id: string) => queryOptions({
queryKey: ["users", id],
queryFn: async () => {
const res = await fetch(`/api/users/${id}`);
if (!res.ok) throw new Error("Failed to fetch");
return res.json();
},
staleTime: 1000 * 60 * 5, // 5 min
});
export function UserProfile({ id }: { id: string }) {
// Guaranteed data availability via Suspense
const { data: user } = useSuspenseQuery(userOptions(id));
return <div>Welcome, {user.name}</div>;
}
import { useMutationState } from "@tanstack/react-query";
function PendingUploads() {
const pendingVariables = useMutationState({
filters: { status: "pending", mutationKey: ["upload"] },
select: (mutation) => mutation.state.variables as { fileName: string },
});
return (
<ul>
{pendingVariables.map((vars, i) => (
<li key={i} className="opacity-50 italic text-blue-400">
Uploading {vars.fileName}...
</li>
))}
</ul>
);
}
onSuccess, onError, or onSettled in useQuery. They are removed in v5. Use useEffect or move logic to queryFn.isPending. It replaced isLoading in v5 for "no data yet" states.useQuery without a queryKey. It's the only way to manage the cache effectively.await prefetchQuery on the server. Non-awaited prefetches lead to hydration mismatches.enabled with useSuspenseQuery. It's incompatible with the guarantee of data presence.HydrationBoundary, and "use cache".scripts/audit-query-keys.ts: Checks for non-array query keys or unstable key generation.scripts/generate-query-hook.py: Boilerplate generator for v5 query/mutation pairs.Updated: January 23, 2026 - 16:45
npx skills add YuniorGlez/tanstack-query-expert下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer