react/compose-with-tanstack-query

Implement server-side pagination for TanStack Table v9 with TanStack Query.

28.3k|3.6k|Updated Oct 20, 2016
One-click install
npx skills add https://github.com/TanStack/table --skill react-compose-with-tanstack-query
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react/compose-with-tanstack-query
Source: https://github.com/TanStack/table/tree/main/packages/react-table/skills/react/compose-with-tanstack-query
Command: npx skills add https://github.com/TanStack/table --skill react-compose-with-tanstack-query

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building a server-side paginated data grid with TanStack Table often causes refetch bugs, pagination lockups, and UI flicker when the next page loads.

Core Features & Use Cases

  • Canonical TanStack Query pagination composition: Uses an external pagination atom and keys the query on pagination state so refetching is automatic.
  • Smooth page transitions: Applies placeholderData: keepPreviousData to prevent the table from collapsing to 0 rows during loading.
  • Correct pager behavior: Requires server-provided rowCount so getPageCount() and the pager stay accurate for manual pagination.

Quick Start

Ask your AI to compose a TanStack Table v9 React setup that uses useCreateAtom for PaginationState, an external pagination value included in the React Query queryKey, manual pagination with manualPagination: true, and renders dataQuery.data?.rows with a stable empty fallback while passing rowCount into the table options.

Frequently Asked Questions about react/compose-with-tanstack-query

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement server-side pagination in TanStack Table using React Query?

To implement server-side pagination, include pagination state in the React Query queryKey and enable manualPagination in TanStack Table. This setup ensures queries refetch automatically when the page changes, while dropping the client-side paginatedRowModel.

Why does my TanStack Table collapse to zero rows during page loads?

TanStack Table collapses during page loads because the data resets before the new fetch completes. Applying placeholderData: keepPreviousData in TanStack Query maintains the previous dataset visibility until fresh rows arrive, preventing UI flicker.

How do I keep the pager accurate with manual pagination in TanStack Table?

To keep the pager accurate with manual pagination, pass the total rowCount returned from the server into the TanStack Table options. This allows getPageCount() to calculate correct page counts based on actual server data rather than client rows.

Do I need an external pagination atom for TanStack Query refetching?

Using an external pagination atom like useCreateAtom for PaginationState is required to key the TanStack Query on pagination state. This composition ensures the query refetches automatically whenever the pagination value changes.

What causes pagination lockups in React data grids using TanStack Table?

Pagination lockups in TanStack Table occur when the queryKey lacks pagination state or manualPagination misconfigures the client paginatedRowModel. Including pagination state in the queryKey and dropping the client model resolves these refetch bugs.