SkillAgentSearch skills...

nextjs-tanstack-query

Next.js App Router combined with TanStack Query v5 — HydrationBoundary pattern, Server Actions as mutations, optimistic updates, and infinite scroll

Install / Use

npx skills add PatrickJS/awesome-cursorrules

Installs into whichever agent you are using.

About this skill
📦

Other

Other agent config

Quality Score

89/100

Category

Marketing

Supported Platforms

Cursor

Our assessment of nextjs-tanstack-query

nextjs-tanstack-query scores 89/100 on our quality scale, 256th of 581 Marketing skills we index (top 45%).

Its Other is 3.5 KB long, split into 7 sections with 5 code examples: a solid amount of guidance for an agent.

With 41,108 GitHub stars, it is one of the more widely adopted skills in the catalogue.

Substance
26/30
Structure
18/20
Description
15/15
Adoption
20/20
Freshness
11/15

Maintenance, license and trust

  • The repository was last updated about 5 months ago. That is recent enough to be usable, but agent tooling moves fast, so check the instructions against your agent's current version.
  • Our last check on 2026-10-17 found the source still online.
  • It is released under the CC0-1.0 license, a permissive license that allows use, modification and commercial use with attribution.
  • Its trust signals score 98/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

Safety scan

No issues found

Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.

AI review by kimi-k2.7-code on 2026-09-24. Automated pattern scan on 2026-09-24. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.

nextjs-tanstack-query compared with similar skills

All 4 of these similar skills score higher than nextjs-tanstack-query; compare them before choosing.

SkillScoreStarsUpdatedFormat
nextjs-tanstack-query (this skill)by PatrickJS8941.1k5mo agoOther
Agent-Reachby Panniantong100109.2ktodayCLAUDE.md
headroomby headroomlabs-ai10078.9ktodayCLAUDE.md
Scraplingby D4Vinci10097.9ktodayMCP Server
crawl4aiby unclecode10087.0k1d agoMCP Server

Frequently asked questions

How do I install nextjs-tanstack-query?
Run npx skills add PatrickJS/awesome-cursorrules. The install tabs above show the steps for each supported agent.
Which AI agents does nextjs-tanstack-query work with?
It is written for Cursor, as a Other file. Other agents that read the same format can often use it too.
Is nextjs-tanstack-query safe to use?
Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is CC0-1.0-licensed and scores 98/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is nextjs-tanstack-query still maintained?
The repository was last updated about 5 months ago. That is recent enough to be usable, but agent tooling moves fast, so check the instructions against your agent's current version.

description: "Next.js App Router combined with TanStack Query v5 — HydrationBoundary pattern, Server Actions as mutations, optimistic updates, and infinite scroll" globs: ["app//*.tsx", "app//.ts", "src/app/**/.tsx", "src/queries/**/*"] alwaysApply: false

You are an expert in Next.js App Router, TanStack Query v5, TypeScript, and combining server components with client-side data fetching.

Architecture

  • Server Components fetch data directly — no TanStack Query needed there
  • TanStack Query lives in Client Components for interactive, real-time, or mutation-driven data
  • Hydrate the Query cache from server to avoid client waterfalls on first load
  • Use React Server Components for initial page data; TanStack Query for mutations + polling + optimistic UI

Provider Setup

// providers/query-provider.tsx
'use client'
export function QueryProvider({ children }: { children: React.ReactNode }) {
  const [queryClient] = useState(() => new QueryClient({
    defaultOptions: { queries: { staleTime: 60 * 1000 } },
  }))
  return (
    <QueryClientProvider client={queryClient}>
      {children}
      <ReactQueryDevtools initialIsOpen={false} />
    </QueryClientProvider>
  )
}

Server Prefetch + HydrationBoundary Pattern

// app/posts/page.tsx  (Server Component)
export default async function PostsPage() {
  const queryClient = new QueryClient()
  await queryClient.prefetchQuery(postsQueryOptions())
  return (
    <HydrationBoundary state={dehydrate(queryClient)}>
      <PostsList />
    </HydrationBoundary>
  )
}

// app/posts/_components/posts-list.tsx  (Client Component)
'use client'
export function PostsList() {
  const { data: posts } = useQuery(postsQueryOptions())  // reads from pre-populated cache
  return <ul>{posts?.map(p => <li key={p.id}>{p.title}</li>)}</ul>
}

queryOptions Factory

export const postsQueryOptions = (filters?: PostFilters) =>
  queryOptions({
    queryKey: ['posts', 'list', filters],
    queryFn: () => fetch('/api/posts').then(r => r.json()),
  })

Server Actions as mutationFn

// app/posts/actions.ts
'use server'
export async function createPost(data: { title: string; body: string }) {
  const post = await db.post.create({ data })
  revalidatePath('/posts')
  return post
}

// usage in Client Component
const mutation = useMutation({
  mutationFn: createPost,
  onSuccess: () => queryClient.invalidateQueries({ queryKey: ['posts', 'list'] }),
})

Optimistic Updates

const mutation = useMutation({
  mutationFn: updatePost,
  onMutate: async (updated) => {
    await queryClient.cancelQueries({ queryKey: ['posts', 'detail', updated.id] })
    const previous = queryClient.getQueryData(['posts', 'detail', updated.id])
    queryClient.setQueryData(['posts', 'detail', updated.id], (old: Post) => ({ ...old, ...updated }))
    return { previous }
  },
  onError: (_, updated, ctx) => {
    queryClient.setQueryData(['posts', 'detail', updated.id], ctx?.previous)
  },
  onSettled: (_, __, updated) => {
    queryClient.invalidateQueries({ queryKey: ['posts', 'detail', updated.id] })
  },
})

Key Rules

  • Create a new QueryClient per request in Server Components — never reuse across requests
  • Create one QueryClient per browser session via useState in the provider
  • Always wrap server-prefetched subtrees in HydrationBoundary
  • Mark all components using TanStack Query hooks with 'use client'
  • Never call fetch directly in Client Components — always go through queryFn

Related Skills

View on GitHub
GitHub Stars41.1k
CategoryMarketing
Updated5mo ago
Forks3.5k

Languages

JavaScript

Trust signals

98/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

1 info