router-core/data-loading

Load TanStack Router route data with caching, pending states, and errors.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/guillempuche/engranatge --skill router-core-data-loading-guillempuche
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/data-loading
Source: https://github.com/guillempuche/engranatge/tree/main/docs/repos/tanstack-router/packages/router-core/skills/router-core/data-loading
Command: npx skills add https://github.com/guillempuche/engranatge --skill router-core-data-loading-guillempuche

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It simplifies loading and caching data for dynamic routes, providing built‑in handling for pending states and errors.

Core Features & Use Cases

  • Loader functions fetch data for each route.
  • loaderDeps generate cache keys from search parameters.
  • Stale‑while‑revalidate caching with configurable staleTime and gcTime.
  • Pending components and timing control for smoother UI.
  • Router context creation to share utilities across loaders.
  • Invalidation to refresh data after mutations.
  • Deferred data loading with unawaited promises and the Await component.

Quick Start

Navigate to a route such as /posts and retrieve its loaded data using the router’s loader hook.

Frequently Asked Questions about router-core/data-loading

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

FAQPage Schema
How do I load and cache route data in a React application using TanStack Router?

You load and cache route data by defining loader functions for your routes. TanStack Router handles the data fetching, caching, and pending states automatically to streamline UI rendering.

What is the best way to handle pending states and errors when fetching dynamic route data?

The best way to handle pending states and errors is using built-in pending components. You can configure timing control for smoother UI transitions while the loader functions fetch route data.

How does stale-while-revalidate caching work with TanStack Router loaders?

Stale-while-revalidate caching works by configuring staleTime and gcTime. It serves cached data immediately while revalidating in the background, refreshing route data when it becomes stale.

Can I generate cache keys from search parameters for my React route loaders?

Yes, you can generate cache keys from search parameters using loaderDeps. This ensures that route data caching remains unique and responsive to changing URL search parameters.

Do I need TanStack Router and React to use loader functions for data fetching?

Yes, you need TanStack Router version 1.166.2 and React. These provide the foundational router context and hooks required to execute loader functions and manage route data.

How do I refresh data after mutations invalidate the route cache?

You refresh data after mutations by using router invalidation mechanisms. This clears the stale cache and triggers the loader functions to fetch fresh route data automatically.