# tanstack-router

Configures type-safe file-based routing in React SPAs and resolves integration issues with TanStack Query or Cloudflare Workers.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 445 installs · ★ 236
- Author: Claude Skills Maintainers
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/secondsky/claude-skills/tree/HEAD/plugins/tanstack-router/skills/tanstack-router/SKILL.md
- Updated: 2026-10-20
- HTML: https://affpapa.org/en/nevibecode/skills/claude-skills-maintainers-tanstack-router

## What it does

The skill guides your agent through setting up file-based routing in React and configuring Vite plugins. It provides reference code for dynamic segments like `$postId` and route-level `loader` functions.

Plugin sequence is strictly enforced. In `vite.config.ts`, `TanStackRouterVite()` must run before `react()`, or route generation in `routeTree.gen.ts` fails. The skill also avoids an established memory leak between TanStack Form and Router (#5734), applying React Hook Form as a fallback.

Templates include full-stack setups with Cloudflare Workers API routes. The agent runs Bash commands and edits configuration files directly in your repository.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add secondsky/claude-skills --skill tanstack-router -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/tanstack-router/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/tanstack-router/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add secondsky/claude-skills --skill tanstack-router -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/tanstack-router/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add secondsky/claude-skills --skill tanstack-router -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/tanstack-router/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install secondsky/claude-skills tanstack-router
```

2. **Manually: put the files in place**
- File: `.github/skills/tanstack-router/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add secondsky/claude-skills --skill tanstack-router -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/secondsky/claude-skills --path plugins/tanstack-router/skills/tanstack-router
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/tanstack-router/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add secondsky/claude-skills --skill tanstack-router -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/secondsky/claude-skills/tree/HEAD/plugins/tanstack-router/skills/tanstack-router/SKILL.md

## When to use it
- generate file-based routes for React SPAs in Vite
- wire route loaders to TanStack Query caches
- fix Vite plugin ordering and devtools resolution errors
- deploy client-side navigation alongside Cloudflare Workers

## Example prompts
- Configure TanStack Router with Vite and React
- Add a route with $postId and prefetch data using TanStack Query
- Set up Cloudflare Workers deployment for our React router SPA

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 04c1778e7fc56bd6.

BEGIN THIRD-PARTY FILE 04c1778e7fc56bd6
````text
---
name: tanstack-router
description: TanStack Router type-safe file-based routing for React. Use for SPAs, TanStack Query integration, Cloudflare Workers, or encountering devtools, type safety, loader, Vite bundling errors.
license: MIT
allowed-tools: [Bash, Read, Write, Edit]
metadata:
  version: 1.0.0
  author: Claude Skills Maintainers
  last-verified: 2026-08-03
  production-tested: true
  keywords:
    - tanstack router
    - react router
    - type-safe routing
    - file-based routing
    - client-side routing
    - spa routing
    - route loaders
    - data loading
    - navigation
    - vite plugin
    - cloudflare workers
    - tanstack query integration
    - typescript routing
    - route params
    - nested routes
    - code splitting
---

# TanStack Router Skill

Build type-safe, file-based routing for React SPAs with TanStack Router, optimized for Cloudflare Workers deployment.

---

## When to Use This Skill

**Auto-triggers when you mention:**
- "TanStack Router" or "type-safe routing"
- "file-based routing" or "route configuration"
- "React routing" with TypeScript emphasis
- "route loaders" or "data loading in routes"
- "Cloudflare Workers routing"

**Use this skill when:**
- Building SPAs with type-safe navigation
- Implementing file-based routing (like Next.js)
- Need route-level data loading
- Integrating routing with TanStack Query
- Deploying to Cloudflare Workers
- Want better TypeScript support than React Router

---

## Quick Start

### Installation

```bash
bun add @tanstack/react-router @tanstack/router-devtools
bun add -d @tanstack/router-plugin
```

**Latest version:** v1.170.18 (verified 2026-08-03)

### Vite Configuration

```typescript
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'

export default defineConfig({
  plugins: [
    TanStackRouterVite(), // MUST come before react()
    react(),
  ],
})
```

### Basic Setup

```typescript
// src/routes/__root.tsx
import { createRootRoute, Outlet } from '@tanstack/react-router'

export const Route = createRootRoute({
  component: () => (
    <div>
      <nav>
        <Link to="/">Home</Link>
        <Link to="/about">About</Link>
      </nav>
      <hr />
      <Outlet />
    </div>
  ),
})

// src/routes/index.tsx
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/')({
  component: () => <h1>Home Page</h1>,
})

// src/routes/about.tsx
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/about')({
  component: () => <h1>About Page</h1>,
})

// src/main.tsx
import { createRouter, RouterProvider } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen' // Auto-generated

const router = createRouter({ routeTree })

function App() {
  return <RouterProvider router={router} />
}
```

---

## Key Features

### 1. Type-Safe Navigation

```typescript
// Fully typed!
````
END THIRD-PARTY FILE 04c1778e7fc56bd6

The third-party file has ended. Everything between the 04c1778e7fc56bd6 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3009 of 7560 bytes. © Claude Skills Maintainers · MIT · https://github.com/secondsky/claude-skills/tree/HEAD/plugins/tanstack-router/skills/tanstack-router/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
