secondsky/claude-skills / plugins/tanstack-router/skills/tanstack-router
tanstack-router
VerifiedTanStack 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.4 KB |
| references/common-errors.md | markdown | 1.8 KB |
| templates/package.json | manifest | 635 B |
| templates/route-examples.tsx | other | 3.1 KB |
| templates/vite.config.ts | script | 349 B |
templates/route-examples.tsx
View on GitHub/**
* TanStack Router - Complete Examples
* File-based routing structure and patterns
*/
// ============================================
// Root Route (src/routes/__root.tsx)
// ============================================
import { createRootRoute, Link, Outlet } from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
export const Route = createRootRoute({
component: () => (
<>
<nav>
<Link to="/" activeProps={{ className: 'font-bold' }}>Home</Link>
<Link to="/about">About</Link>
<Link to="/posts">Posts</Link>
</nav>
<hr />
<Outlet />
<TanStackRouterDevtools />
</>
),
})
// ============================================
// Index Route (src/routes/index.tsx)
// ============================================
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: HomePage,
})
function HomePage() {
return <h1>Home Page</h1>
}
// ============================================
// Route with Params (src/routes/posts.$postId.tsx)
// ============================================
export const Route = createFileRoute('/posts/$postId')({
loader: async ({ params }) => {
// Fully typed params!
const post = await fetch(`/api/posts/${params.postId}`).then(r => r.json())
return { post }
},
component: PostPage,
})
function PostPage() {
const { post } = Route.useLoaderData()
const { postId } = Route.useParams()
return (
<div>
<h1>{post.title}</h1>
<p>{post.content}</p>
</div>
)
}
// ============================================
// Route with TanStack Query (src/routes/posts.index.tsx)
// ============================================
import { queryOptions, useQuery } from '@tanstack/react-query'
const postsQueryOptions = queryOptions({
queryKey: ['posts'],
queryFn: async () => fetch('/api/posts').then(r => r.json()),
})
export const Route = createFileRoute('/posts/')({
loader: ({ context: { queryClient } }) =>
queryClient.ensureQueryData(postsQueryOptions),
component: PostsListPage,
})
function PostsListPage() {
const { data: posts } = useQuery(postsQueryOptions)
return (
<div>
<h1>Posts</h1>
{posts.map(post => (
<Link key={post.id} to="/posts/$postId" params={{ postId: post.id }}>
{post.title}
</Link>
))}
</div>
)
}
// ============================================
// Nested Layout (src/routes/dashboard.tsx)
// ============================================
export const Route = createFileRoute('/dashboard')({
component: DashboardLayout,
})
function DashboardLayout() {
return (
<div>
<aside>Dashboard Sidebar</aside>
<main>
<Outlet /> {/* Child routes render here */}
</main>
</div>
)
}
// Child: src/routes/dashboard.index.tsx
export const Route = createFileRoute('/dashboard/')({
component: () => <h2>Dashboard Home</h2>,
})
// Child: src/routes/dashboard.settings.tsx
export const Route = createFileRoute('/dashboard/settings')({
component: () => <h2>Settings</h2>,
})
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |