install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/TerminalSkills/skills/tanstack" ~/.claude/skills/comeonoliver-skillshub-tanstack && rm -rf "$T"
manifest:
skills/TerminalSkills/skills/tanstack/SKILL.mdsource content
TanStack
Overview
The TanStack ecosystem provides type-safe client libraries for React: Query for declarative data fetching and caching, Router for fully typed routing with search parameters, Table for headless data tables with sorting/filtering/pagination, and Virtual for rendering large lists efficiently.
Instructions
- When fetching data, use
with hierarchical query keys (e.g.,useQuery()
) and configure["users", userId, "posts"]
based on freshness needs (0 for real-time, 5 minutes for dashboards, Infinity for static data).staleTime - When performing mutations, use
withuseMutation()
for cache invalidation viaonSuccess
, andqueryClient.invalidateQueries()
for optimistic updates with rollback.onMutate - When building tables, use TanStack Table's headless approach with typed column definitions, and combine with
for datasets with 10,000+ rows.@tanstack/react-virtual - When routing, use TanStack Router for fully typed route parameters and search params with Zod validation, file-based routes with automatic type generation, and route-level data loading.
- When handling pagination, use
for infinite scroll or cursor-based patterns, and server-side pagination in TanStack Table.useInfiniteQuery() - When prefetching, use
for anticipated navigation andqueryClient.prefetchQuery()
for React Suspense integration.useSuspenseQuery() - When virtualizing lists, use
with@tanstack/react-virtual
for scroll position prediction and support for dynamic, variable-height items.estimateSize
Examples
Example 1: Build a data dashboard with Query and Table
User request: "Create a dashboard with server-paginated data table and real-time stats"
Actions:
- Set up TanStack Query with appropriate
and refetch intervals for statsstaleTime - Define TanStack Table with typed columns, server-side sorting and pagination
- Implement filter controls with column filters and global search
- Add optimistic updates for inline row editing with mutation rollback
Output: A dashboard with efficient data fetching, server-managed table pagination, and instant edit feedback.
Example 2: Add type-safe routing with data prefetching
User request: "Set up TanStack Router with typed search parameters and data preloading"
Actions:
- Define routes with typed parameters and Zod-validated search params
- Add route loaders for data fetching with built-in caching
- Configure
components with type-checked params and search params<Link> - Enable prefetching on hover for instant navigation
Output: A fully typed routing layer where invalid params cause TypeScript errors at compile time.
Guidelines
- Use query key factories for consistent cache keys:
.const userKeys = { all: ["users"], detail: (id) => ["users", id] } - Set
based on data freshness needs: 0 for real-time, 5 minutes for dashboards, Infinity for static data.staleTime - Always define
for mutations; silent failures confuse users.onError - Use
instead ofplaceholderData
for loading states; placeholder does not write to cache.initialData - Use TanStack Table with
for large datasets; do not render thousands of DOM nodes.@tanstack/react-virtual - Keep query functions pure: they receive
and return data with no side effects.queryKey - Use
after mutations instead of manual cache updates for simplicity.queryClient.invalidateQueries()