skills/tanstack-router/SKILL.md
TanStack Router best practices for type-safe routing, data loading, search params, and navigation. Activate when building React applications with complex routing needs.
npx skillsauth add cenjie/skills tanstack-router-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive guidelines for implementing TanStack Router patterns in React applications. These rules optimize type safety, data loading, navigation, and code organization.
| Priority | Category | Rules | Impact | |----------|----------|-------|--------| | CRITICAL | Type Safety | 4 rules | Prevents runtime errors and enables refactoring | | CRITICAL | Route Organization | 5 rules | Ensures maintainable route structure | | HIGH | Router Config | 1 rule | Global router defaults | | HIGH | Data Loading | 6 rules | Optimizes data fetching and caching | | HIGH | Search Params | 5 rules | Enables type-safe URL state | | HIGH | Error Handling | 1 rule | Handles 404 and errors gracefully | | MEDIUM | Navigation | 5 rules | Improves UX and accessibility | | MEDIUM | Code Splitting | 3 rules | Reduces bundle size | | MEDIUM | Preloading | 3 rules | Improves perceived performance | | LOW | Route Context | 3 rules | Enables dependency injection |
ts-)ts-register-router — Register router type for global inferencets-use-from-param — Use from parameter for type narrowingts-route-context-typing — Type route context with createRootRouteWithContextts-query-options-loader — Use queryOptions in loaders for type inferencerouter-)router-default-options — Configure router defaults (scrollRestoration, defaultErrorComponent, etc.)org-)org-file-based-routing — Prefer file-based routing for conventionsorg-route-tree-structure — Follow hierarchical route tree patternsorg-pathless-layouts — Use pathless routes for shared layoutsorg-index-routes — Understand index vs layout routesorg-virtual-routes — Understand virtual file routesload-)load-use-loaders — Use route loaders for data fetchingload-loader-deps — Define loaderDeps for cache controlload-ensure-query-data — Use ensureQueryData with TanStack Queryload-deferred-data — Split critical and non-critical dataload-error-handling — Handle loader errors appropriatelyload-parallel — Leverage parallel route loadingsearch-)search-validation — Always validate search paramssearch-type-inheritance — Leverage parent search param typessearch-middleware — Use search param middlewaresearch-defaults — Provide sensible defaultssearch-custom-serializer — Configure custom search param serializerserr-)err-not-found — Handle not-found routes properlynav-)nav-link-component — Prefer Link component for navigationnav-active-states — Configure active link statesnav-use-navigate — Use useNavigate for programmatic navigationnav-relative-paths — Understand relative path navigationnav-route-masks — Use route masks for modal URLssplit-)split-lazy-routes — Use .lazy.tsx for code splittingsplit-critical-path — Keep critical config in main route filesplit-auto-splitting — Enable autoCodeSplitting when possiblepreload-)preload-intent — Enable intent-based preloadingpreload-stale-time — Configure preload stale timepreload-manual — Use manual preloading strategicallyctx-)ctx-root-context — Define context at root routectx-before-load — Extend context in beforeLoadctx-dependency-injection — Use context for dependency injectionEach rule file in the rules/ directory contains:
See individual rule files in rules/ directory for detailed guidance and code examples.
development
Provides React Native performance optimization guidelines for FPS, TTI, bundle size, memory leaks, re-renders, and animations. Applies to tasks involving Hermes optimization, JS thread blocking, bridge overhead, FlashList, native modules, or debugging jank and frame drops.
development
Design engineering principles for making interfaces feel polished. Use when building UI components, reviewing frontend code, implementing animations, hover states, shadows, borders, typography, micro-interactions, enter/exit animations, or any visual detail work. Triggers on UI polish, design details, "make it feel better", "feels off", stagger animations, border radius, optical alignment, font smoothing, tabular numbers, image outlines, box shadows.
development
General-purpose Static Application Security Testing (SAST) skill for code vulnerability analysis. Trigger when the user asks to: "analyze code for vulnerabilities", "review code security", "find security bugs", "do a SAST scan", "check for [vulnerability type] in code", "audit source code", or requests a security code review of any language or framework. Covers 34 vulnerability classes across web, API, auth, mobile, and logic layers.
tools
Helps understand and write EAS workflow YAML files for Expo projects. Use this skill when the user asks about CI/CD or workflows in an Expo or EAS context, mentions .eas/workflows/, or wants help with EAS build pipelines or deployment automation.