TanStack Router
БесплатноБез исполняемых скриптовНе проверенExpert guidance for TanStack Router including file-based routing, type-safe navigation, route loaders, search params, nested routes, and lazy loading. Use…
Об этом скилле
TanStack Router
Expert assistance with TanStack Router - Type-safe routing for React.
Overview
TanStack Router is a fully type-safe React router:
- File-Based Routing: Automatic route generation from file structure
- Type Safety: Full TypeScript inference for params, search, and more
- Code Splitting: Automatic route-based code splitting
- Data Loading: Built-in data loaders
- Search Params: Type-safe search parameter handling
Installation
npm install @tanstack/react-router
npm install --save-dev @tanstack/router-vite-plugin
Basic Setup
Vite Configuration
// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { TanStackRouterVite } from '@tanstack/router-vite-plugin';
export default defineConfig({
plugins: [
react(),
TanStackRouterVite(),
],
});
Root Route
// src/routes/__root.tsx
import { createRootRoute, Outlet } from '@tanstack/react-router';
export const Route = createRootRoute({
component: () => (
<>
<div>
<nav>
<Link to="/">Home</Link>
<Link to="/certificates">Certificates</Link>
</nav>
</div>
<hr />
<Outlet />
</>
),
});
Index Route
// src/routes/index.tsx
import { createFileRoute } from '@tanstack/react-router';
export const Route = createFileRoute('/')({
component: () => <div>Home Page</div>,
});
File-Based Routing
src/routes/
├── __root.tsx -> /
├── index.tsx -> /
├── certificates/
│ ├── index.tsx -> /certificates
│ └── $id.tsx -> /certificates/:id
├── cas/
│ ├── index.tsx -> /cas
│ ├── $id.tsx -> /cas/:id
│ └── $id.edit.tsx -> /cas/:id/edit
└── audit.tsx -> /audit
Dynamic Routes
// src/routes/certificates/$id.tsx
import { createFileRoute } from '@tanstack/react-router';
export const Route = createFileRoute('/certificates/$id')({
component: CertificateDetail,
});
function CertificateDetail() {
const { id } = Route.useParams(); // Type-safe!
return <div>Certificate: {id}</div>;
}
Nested Routes
// src/routes/certificates.tsx (layout)
import { createFileRoute, Outlet } from '@tanstack/react-router';
export const Route = createFileRoute('/certificates')({
component: () => (
<div>
<h1>Certificates</h1>
<Outlet /> {/* Render child routes */}
</div>
),
});
// src/routes/certificates/index.tsx
export const Route = createFileRoute('/certificates/')({
component: () => <div>Certificate List</div>,
});
// src/routes/certificates/$id.tsx
export const Route = createFileRoute('/certificates/$id')({
component: () => {
const { id } = Route.useParams();
return <div>Certificate {id}</div>;
},
});
Navigation
import { Link, useNavigate } from '@tanstack/react-router';
function MyComponent() {
const navigate = useNavigate();
return (
<>
{/* Link component */}
<Link to="/certificates">Certificates</Link>
{/* With params */}
<Link to="/certificates/$id" params={{ id: '123' }}>
Certificate 123
</Link>
{/* With search params */}
<Link to="/certificates" search={{ filter: 'active' }}>
Active Certificates
</Link>
{/* Programmatic navigation */}
<button onClick={() => navigate({ to: '/certificates' })}>
Go to Certificates
</button>
{/* Navigate with params */}
<button onClick={() => navigate({
to: '/certificates/$id',
params: { id: '123' },
})}>
View Certificate
</button>
</>
);
}
Search Params
Define Search Schema
import { createFileRoute } from '@tanstack/react-router';
import { z } from 'zod';
const searchSchema = z.object({
filter: z.enum(['all', 'active', 'revoked']).optional().default('all'),
page: z.number().optional().default(1),
pageSize: z.number().optional().default(10),
});
export const Route = createFileRoute('/certificates/')({
validateSearch: searchSchema,
component: CertificateList,
});
function CertificateList() {
const { filter, page, pageSize } = Route.useSearch(); // Type-safe!
return (
<div>
<p>Filter: {filter}, Page: {page}</p>
</div>
);
}
Update Search Params
import { useNavigate } from '@tanstack/react-router';
function FilterButtons() {
const navigate = useNavigate({ from: '/certificates' });
const search = Route.useSearch();
return (
<>
<button onClick={() => navigate({
search: (prev) => ({ ...prev, filter: 'active' }),
})}>
Active
</button>
<button onClick={() => navigate({
search: { filter: 'revoked', page: 1 },
})}>
Revoked
</button>
</>
);
}
Route Loaders
Установить TanStack Router в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл TanStack Router?
Expert guidance for TanStack Router including file-based routing, type-safe navigation, route loaders, search params, nested routes, and lazy loading. Use this when building type-safe React applications with client-side routing.
Как установить скилл TanStack Router?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл TanStack Router запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
agent-skill-stack
Find, evaluate, and assemble the smallest compatible set of AI Agent Skills for an end-to-end natural-language goal. Use when a user wants Skills for a…
от GitHubbuild-evidence-map
Build an auditable evidence map for a contested technical choice, research synthesis, proposal review, or consequential decision. Use when Copilot must…
от GitHubpinecone-rag
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions…
от GitHubqdrant-monitoring-debugging
Diagnoses Qdrant production issues using metrics and observability tools. Use when someone reports 'optimizer stuck', 'indexing too slow', 'memory too high'…
от GitHub