router-core/data-loading

Coordinate TanStack Router route data loading with parameter-aware caching and preloading.

4|1|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/lespaceman/athena-workflow-marketplace --skill router-core-data-loading-lespaceman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/data-loading
Source: https://github.com/lespaceman/athena-workflow-marketplace/tree/main/plugins/tanstack-start/skills/upstream/%40tanstack/router-core/skills/router-core/data-loading
Command: npx skills add https://github.com/lespaceman/athena-workflow-marketplace --skill router-core-data-loading-lespaceman

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Route data loading for TanStack Router can be complex to manage, with cache keys, preloading, and error handling across nested routes.

Core Features & Use Cases

  • Loader with cache keys via loaderdeps for dynamic params and search parameters
  • SWR-like caching with staleTime and gcTime to balance freshness and performance
  • beforeLoad, router.invalidate, and error handling for robust recovery
  • Deferred data loading with Await for non-blocking UX
  • Context sharing via beforeLoad/loader to provide data across routes

Quick Start

Configure a file-based route with a loader function, a loaderDeps-derived cache key, and optional pending state to fetch and render data.

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 manage route data loading and caching in a TanStack Router SPA?

Route data loading in TanStack Router is managed by coordinating client-side loaders with parameter-aware caching, using loaderDeps for cache keys and staleTime to balance freshness and performance across nested routes.

How do I set up cache keys for dynamic route parameters in TanStack Router?

Cache keys for dynamic route parameters are set up using loaderDeps, which allows the loader function to derive unique cache entries based on search parameters and dynamic URL segments.

Can I defer non-critical data loading to improve UX in TanStack Router?

Deferred data loading is supported using Await patterns, allowing non-blocking UX by rendering pending states while secondary route data fetches complete in the background.

What is the best way to handle errors and context sharing across nested routes?

Error handling and context sharing across nested routes are handled via beforeLoad functions and router.invalidate, providing robust recovery mechanisms and injecting contextual data into downstream loaders.

Does this data loading approach work for preloading and SWR-like caching?

Preloading and SWR-like caching are supported by configuring staleTime and gcTime, ensuring route data remains fresh while optimizing performance through background revalidation and garbage collection.

Why are my nested route loaders fetching duplicate data with different search parameters?

Duplicate fetches occur when loaderDeps are not configured to track specific search parameters, causing cache misses; defining explicit loaderDeps ensures proper cache key generation for parameter-aware data loading.