router-core/type-safety

Configure TanStack Router type registration for full type inference without casts.

Updated Apr 1, 2026
One-click install
npx skills add https://github.com/cill-i-am/task-tracker --skill router-core-type-safety-cill-i-am
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-core/type-safety
Source: https://github.com/cill-i-am/task-tracker/tree/main/.agents/skills/tanstack-router-type-safety
Command: npx skills add https://github.com/cill-i-am/task-tracker --skill router-core-type-safety-cill-i-am

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Fully type-inferred usage of TanStack Router to avoid casts and explicit annotations, enabling safer route data handling.

Core Features & Use Cases

  • Type inference-first architecture: no required casts or explicit generics; routes and hooks infer types automatically.
  • Register module declarations: one-time type registration to enable strong typing across Link, useNavigate, useParams, and useLoaderData.
  • Utilities for code-splitting and performance: getRouteApi, addChildren with object syntax, and type utilities like ValidateLinkOptions to keep types precise and scalable.
  • Real-world scenario: build large apps with nested routes where type safety propagates through context and loader data.

Quick Start

Configure your project to enable full type inference for TanStack Router by registering types once and using file-based routes without explicit type casts.

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 type inference in TanStack Router without using explicit generics?

To enable type inference in TanStack Router without explicit generics, perform a one-time type registration using module declarations. This automatically infers types across Link, useNavigate, useParams, and useLoaderData.

Why does my useLoaderData hook return untyped data in TanStack Router?

Your useLoaderData hook returns untyped data because the root route types are not registered. Performing a one-time type registration propagates strong typing through context and loader data automatically across all file-based routes.

What is the best way to maintain type safety when code-splitting TanStack Router routes?

The best way to maintain type safety when code-splitting TanStack Router routes is using the getRouteApi utility. It enforces static type registration and keeps types precise without requiring unsafe casts or explicit annotations.

Can I use file-based routes with TanStack Router and still get full type narrowing?

Yes, you can use file-based routes with TanStack Router and get full type narrowing. By registering types once and using hook narrowing with from selectors, type safety propagates through nested routes without explicit type casts.

Do I need to manually annotate ValidateLinkOptions for large TanStack Router applications?

No, you do not need to manually annotate ValidateLinkOptions for large TanStack Router applications. The type-inference-first architecture uses type utilities to keep types precise and scalable without explicit annotations.