tanstack-router

tanstack-router is a cursor rule for Cursor from louisbrulenaudet/monorepo-template. It costs 0 tokens per session (648 once invoked), scanned A, original, Apache-2.0.

A set of rules for TanStack Router, a library for moving between pages in a client-side web application. It covers file-based routes, typed links, search parameters, route loading, and the split between route logic and page interface code.

In plain words
What is it for?
Use it when adding pages, navigation, URL search parameters, authentication redirects, route preloading, or lazy-loaded page interfaces in a React single-page app.
Why use it?
It prevents inconsistent navigation, hand-edited generated files, duplicated routers, and route files becoming difficult to maintain. It also coordinates route loading with cached server data.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when adding pages, navigation, URL search parameters, authentication redirects, route preloading, or lazy-loaded page interfaces in a React single-page app.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/louisbrulenaudet/monorepo-template/tanstack-router
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/louisbrulenaudet/monorepo-template

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tanstack-router

README.md
[![agentmods](https://agentmods.dev/badge/rules/louisbrulenaudet/monorepo-template/tanstack-router/github.svg)](https://agentmods.dev/rules/louisbrulenaudet/monorepo-template/tanstack-router)
Your own site
<a href="https://agentmods.dev/rules/louisbrulenaudet/monorepo-template/tanstack-router"><img src="https://agentmods.dev/badge/rules/louisbrulenaudet/monorepo-template/tanstack-router/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tanstack-router

Your own site · 80×15
<a href="https://agentmods.dev/rules/louisbrulenaudet/monorepo-template/tanstack-router"><img src="https://agentmods.dev/badge/rules/louisbrulenaudet/monorepo-template/tanstack-router.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 648 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00648
Opus 5.5 $0.00000 $0.00259
Sonnet 5.5 $0.00000 $0.00130
Haiku 4.5 $0.00000 $0.00065

Measured 15d ago against content hash c64a66f46a65, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

tanstack-router scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 15d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/frontend/tanstack-router.mdc · 20 lines

What it actually says

TanStack Router (v1)

Client-side routing only: ignore TanStack Start, SSR, and server functions. Depth: skill tanstack-router.

  • File-based routing through the Vite plugin (tanstackRouter before @vitejs/plugin-react, vite-config.mdc).
  • routeTree.gen.ts is generated and committed: never hand-edit it (hook-enforced); regenerate with the app's routes:generate / routes:check. It is excluded from OXC. routes:check diffs the working tree against the git index, so git add the regenerated file before re-running check-types.
  • Register the router once (declare module "@tanstack/react-router" { interface Register { router: typeof router } }): one router, one <RouterProvider>, defaultPreload: "intent", scrollRestoration: true.
  • Two layers: src/routes/<path>.tsx (loaders, guards, validateSearch, and component) → src/pages/<Page>.tsx. Route files stay thin. autoCodeSplitting already moves component into its own chunk, so never add a .lazy.tsx file.
  • Typed <Link> / useNavigate() only - no hand-built internal URLs. Search params: validateSearch with a Zod v4 schema passed directly (native support; never reintroduce @tanstack/zod-adapter), .catch() fallbacks to keep inference, loaderDeps when loaders depend on search.
  • Auth and redirects in beforeLoad, not render; throw notFound() from loaders when appropriate.
  • Page title: render a React 19 <title> in the page component; react-dom inserts it ahead of the static index.html title, so it wins while mounted. Never add a route head() without mounting <HeadContent /> in RootLayout: head() renders nothing without it.
  • With the first loader route, wrap the router-free RouteErrorFallback in a route-level error component that retries with router.invalidate() plus useQueryErrorResetBoundary().reset(): the router's reset() alone does not re-run loaders.
  • Query integration: queryClient on the root context; loaders call queryClient.query({ ...opts, staleTime: "static" }); components useSuspenseQuery(opts). Await in a loader only data the route renders through useSuspenseQuery: a rejecting loader swaps the page for errorComponent, so optional data (the stack check) stays with its component's useQuery. Set defaultPreloadStaleTime: 0 so Query's staleTime owns freshness (a common misconfiguration).
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 15d ago Changed · +2 lines c64a66f46a65
  2. 23d ago Changed · -2 lines 03077eb2f1e4
  3. 25d ago Changed 8cad67301216
  4. 27d ago Changed 93f9195592f4
  5. 1mo ago First seen · 20 lines · 0 tokens per session scan A e4c017e39c76

Subscribe to this mod's changes

tanstack-router is a cursor rule published in the GitHub repository louisbrulenaudet/monorepo-template (19 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 648 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.