tanstack-router-react-cursorrules-prompt-file
Cursor rules for TanStack Router v1 with file-based routing, typed params, search validation, loaders, auth guards, and route preloading.
Install / Use
npx skills add PatrickJS/awesome-cursorrulesInstalls into whichever agent you are using.
Other
Other agent config
Quality Score
Category
AutomationSupported Platforms
Our assessment of tanstack-router-react-cursorrules-prompt-file
tanstack-router-react-cursorrules-prompt-file scores 91/100 on our quality scale, 60th of 660 Automation skills we index (top 10%).
Its Other is 5.8 KB long, well organised into 14 sections with 8 code examples: a solid amount of guidance for an agent.
With 40,832 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 4 months ago. That is recent enough to be usable, but agent tooling moves fast, so check the instructions against your agent's current version.
- Our last check on 2026-09-24 found the source still online.
- It is released under the CC0-1.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 98/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-09-23. Automated pattern scan on 2026-09-24. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
tanstack-router-react-cursorrules-prompt-file compared with similar skills
All 4 of these similar skills score higher than tanstack-router-react-cursorrules-prompt-file; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| tanstack-router-react-cursorrules-prompt-file (this skill)by PatrickJS | 91 | 40.8k | 4mo ago | Other |
| Agent-Reachby Panniantong | 100 | 85.2k | 9d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 73.7k | today | CLAUDE.md |
| rufloby ruvnet | 100 | 73.2k | today | CLAUDE.md |
| Scraplingby D4Vinci | 100 | 83.3k | today | MCP Server |
Frequently asked questions
- How do I install tanstack-router-react-cursorrules-prompt-file?
- Run
npx skills add PatrickJS/awesome-cursorrules. The install tabs above show the steps for each supported agent. - Which AI agents does tanstack-router-react-cursorrules-prompt-file work with?
- It is written for Cursor, as a Other file. Other agents that read the same format can often use it too.
- Is tanstack-router-react-cursorrules-prompt-file safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is CC0-1.0-licensed and scores 98/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is tanstack-router-react-cursorrules-prompt-file still maintained?
- The repository was last updated about 4 months ago. That is recent enough to be usable, but agent tooling moves fast, so check the instructions against your agent's current version.
Skill content
View source on GitHubdescription: "Cursor rules for TanStack Router v1 with file-based routing, typed params, search validation, loaders, auth guards, and route preloading." globs: */ alwaysApply: false
You are an expert in TanStack Router, React, TypeScript, and modern type-safe client-side routing.
TanStack Router + React Guidelines
Core Philosophy
- TanStack Router is 100% type-safe — leverage TypeScript generics for route params, search params, and loader data
- Prefer file-based routing for scalability; use code-based routing only for highly dynamic use cases
- Always define routes with
createFileRouteorcreateRootRoute— never use plain objects - Route data loading belongs in
loaderfunctions, not in componentuseEffect - Search params are first-class citizens — define their schema with Zod or Valibot for validation and type inference
Project Setup
- Use
@tanstack/react-routerwith Vite and the@tanstack/router-vite-pluginfor file-based routing - Enable
routeTree.gen.tsauto-generation — never manually edit this file - Structure routes under
src/routes/directory - Root layout goes in
src/routes/__root.tsx - Use
src/routes/index.tsxfor the home/index route
File-Based Route Conventions
src/routes/
__root.tsx ← Root layout (wraps all routes)
index.tsx ← / route
about.tsx ← /about route
posts/
index.tsx ← /posts route
$postId.tsx ← /posts/:postId (dynamic segment)
_layout.tsx ← Layout route (no path segment)
_auth/
login.tsx ← /login (grouped under auth layout)
(admin)/
dashboard.tsx ← /dashboard (pathless group)
Route Definition Patterns
// src/routes/posts/$postId.tsx
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/posts/$postId')({
loader: async ({ params }) => {
return fetchPost(params.postId) // fully typed params
},
component: PostComponent,
})
function PostComponent() {
const post = Route.useLoaderData() // type-safe loader data
const { postId } = Route.useParams() // type-safe params
return <div>{post.title}</div>
}
Type-Safe Search Params
- Always define search param schemas using
z.object()from Zod - Use
validateSearchoption on route definition - Access with
Route.useSearch()— never read rawwindow.location.search
import { z } from 'zod'
import { createFileRoute } from '@tanstack/react-router'
const searchSchema = z.object({
page: z.number().int().min(1).default(1),
q: z.string().optional(),
})
export const Route = createFileRoute('/search')({
validateSearch: searchSchema,
component: SearchPage,
})
function SearchPage() {
const { page, q } = Route.useSearch()
// ...
}
Navigation
- Use
<Link>from@tanstack/react-router— never<a href>for internal navigation - Use
useNavigate()for programmatic navigation - Always pass typed
paramsandsearchto Link — the compiler will catch mistakes
import { Link, useNavigate } from '@tanstack/react-router'
// Declarative
<Link to="/posts/$postId" params={{ postId: '123' }}>View Post</Link>
// Programmatic
const navigate = useNavigate()
navigate({ to: '/posts/$postId', params: { postId: post.id } })
Loaders & Data Fetching
- Use
loaderfor data that must be available before render (no loading spinners for critical data) - Integrate with TanStack Query by using
ensureQueryDatainside loaders for caching - Use
staleTimeon loaders to avoid redundant fetches during navigation - Return plain serializable data from loaders — no class instances
export const Route = createFileRoute('/posts')({
loader: ({ context: { queryClient } }) =>
queryClient.ensureQueryData(postsQueryOptions()),
component: PostsPage,
})
Error Handling
- Define
errorComponenton routes to handle loader or render errors - Use
notFoundComponentfor 404 states within a route subtree - Use
pendingComponentfor showing skeletons/spinners during data loading
export const Route = createFileRoute('/posts/$postId')({
loader: fetchPost,
errorComponent: ({ error }) => <ErrorBanner message={error.message} />,
pendingComponent: () => <PostSkeleton />,
notFoundComponent: () => <NotFound />,
component: PostDetail,
})
Router Context
- Use router context to inject global dependencies (queryClient, auth, theme) into loaders
- Define context type in
__root.tsxand pass it when creating the router
// __root.tsx
import { createRootRouteWithContext } from '@tanstack/react-router'
interface RouterContext {
queryClient: QueryClient
auth: AuthState
}
export const Route = createRootRouteWithContext<RouterContext>()({
component: RootLayout,
})
// main.tsx
const router = createRouter({
routeTree,
context: { queryClient, auth },
})
Route Guards / Auth
- Use
beforeLoadfor authentication checks — redirect to login if unauthenticated - Never put auth logic inside components — handle it at the routing layer
export const Route = createFileRoute('/_auth/dashboard')({
beforeLoad: ({ context }) => {
if (!context.auth.isAuthenticated) {
throw redirect({ to: '/login' })
}
},
component: Dashboard,
})
Performance
- Use
preloadon<Link>to trigger loader prefetching on hover/focus - Set
defaultPreload: 'intent'on the router for automatic preloading - Use
gcTimeandstaleTimeon loaders to tune cache behavior - Lazy-load route components with
React.lazyfor code splitting
DevTools
- Install
@tanstack/router-devtoolsand render<TanStackRouterDevtools />in development - Use devtools to inspect route tree, active matches, loader data, and search params
Testing
- Use
createMemoryHistoryandcreateRouterto create isolated router instances in tests - Wrap components under test with
<RouterProvider router={testRouter} /> - Mock loaders by providing fake context values
Related Skills
Agent-Reach
85.2kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
73.7kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
ruflo
73.2k🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
Scrapling
83.3k🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
