Tanstack router best practices

From wordbricks/onequery · View interactive version

Tanstack router best practices is an AI agent skill from the GitHub repository wordbricks/onequery. TanStack Router best practices for type-safe routing, data loading, search params, and navigation. Activate when building React applications with complex routing needs.

How to use this skill

Skill file

TanStack Router Best Practices

Comprehensive guidelines for implementing TanStack Router patterns in React applications. These rules optimize type safety, data loading, navigation, and code organization.

When to Apply

Rule Categories by Priority

| 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 |

Quick Reference

Type Safety (Prefix: `ts-`)

Router Config (Prefix: `router-`)

Route Organization (Prefix: `org-`)

Data Loading (Prefix: `load-`)

Search Params (Prefix: `search-`)

Error Handling (Prefix: `err-`)

Navigation (Prefix: `nav-`)

Code Splitting (Prefix: `split-`)

Preloading (Prefix: `preload-`)

Route Context (Prefix: `ctx-`)

How to Use

Each rule file in the rules/ directory contains:

  1. Explanation — Why this pattern matters
  2. Bad Example — Anti-pattern to avoid
  3. Good Example — Recommended implementation
  4. Context — When to apply or skip this rule

Full Reference

See individual rule files in rules/ directory for detailed guidance and code examples.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.