router-core/type-safety

Configure fully inferred types for TanStack Router applications without casts.

14.9k|1.8k|Updated Jan 14, 2019
One-click install
npx skills add https://github.com/TanStack/router --skill router-core-type-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/type-safety
Source: https://github.com/TanStack/router/tree/main/packages/router-core/skills/router-core/type-safety
Command: npx skills add https://github.com/TanStack/router --skill router-core-type-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Router users often struggle with maintaining strict type safety across routes, loaders, and context. This Skill enforces full type inference and prevents pervasive casts, ensuring consistent, reliable typings throughout the app.

Core Features & Use Cases

  • Fully inferred types for route params, search params, and loader data without manual annotations.
  • Clear guidance on Register pattern, from narrowing on hooks, and use of type utilities.
  • Real-world guidance for TS performance and safe coupling with router-core features.

Quick Start

Follow the type-safety guidelines to register router types once and benefit from fully typed hooks and route data across the codebase.

Frequently Asked Questions about router-core/type-safety

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

FAQPage Schema
How do I get fully inferred types for route params and loader data in TanStack Router?

To achieve full type inference for route params, search params, and loader data in TanStack Router, you must apply the required type registration pattern once. This establishes a fully inferred typing regime across the entire routing tree without manual annotations.

Why does TanStack Router lose type safety on hooks and Link components?

TanStack Router loses type safety on hooks and Link components when the router types are not properly registered. Applying the official Register pattern and using from narrowing on hooks restores strict type inference and safe data coupling across the route tree.

What is the best way to prevent type casts in TanStack Router applications?

The best way to prevent type casts in TanStack Router applications is to enforce a fully inferred typing regime. By correctly specifying type registration and leveraging official type utilities, you eliminate unnecessary casts and explicit type annotations throughout your codebase.

Does TanStack Router support full type inference without manual annotations?

Yes, TanStack Router supports full type inference without manual annotations. By guiding type registration and using from narrowing on hooks, the router ensures fully typed route params, search params, and loader data automatically across the codebase.

How do I register router types safely for TypeScript performance in TanStack Router?

To register router types safely for TypeScript performance in TanStack Router, follow the official type-safety guidelines for type registration and rendering optimizations. This approach ensures safe coupling with router-core features while maintaining TS performance.