this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 20 lines 958 B view raw view rendered
1## Route-level prefetch 2 3Route-level prefetching improves perceived performance by initiating data fetches before the user reaches the page. When a link enters the viewport or receives focus, TanStack Router fires the route's `loader` function to pre-warm the query cache. 4 5### How it works 6 71. TanStack Router detects that a link is about to be visited 82. The route's `loader` calls `prefetchQuery` on the query client 93. Data is fetched and cached in React Query's cache 104. When the user clicks, the page renders instantly from cache 11 12### Trade-offs 13 14- **Bandwidth**: May fetch data the user never actually views 15- **Freshness**: Cached data needs an appropriate `staleTime` 16- **Complexity**: Requires defining loaders and query options per route 17 18### Best practices 19 20Set an appropriate `staleTime` to balance data freshness with cache hits. Use `prefetchQuery` for speculative fetches — it won't throw if the query fails, making it safe for preloading.