AGENT SKILL

react-router-architect

Architect-level routing for non-Next React apps — choosing React Router data router vs TanStack Router vs TanStack Start, route tree design, loaders and actions, nested layouts, error/404 boundaries, and URL-as-state rules. Use when designing navigation or migrating a client-rendered SPA.

License 许可
MIT
最近更新
2026-11-13
Stars
★ 0
Forks
0

01 前言 Front Matter

name
react-router-architect
license
MIT
metadata
{ "crusor-path": "website-architect/frontend-development-architect/react-architect/react-router-architect", "crusor-domain": "website-architect", "crusor-origin": "original", "crusor-sources": "reactrouter.com; tanstack.com/router", "crusor-triggers": "react-router, react router, client routing, route loaders, tanstack router, nested routes, url state routing", "crusor-verified-on": "2026-10-30" }
description
Architect-level routing for non-Next React apps — choosing React Router data router vs TanStack Router vs TanStack Start, route tree design, loaders and actions, nested layouts, error/404 boundaries, and URL-as-state rules. Use when designing navigation or migrating a client-rendered SPA.
compatibility
React 18+; React Router 7, TanStack Router/Start

03 SKILL.md 正文

React Router Architect

When to use

  • A client-rendered React app needs navigation, data loading, or guards.
  • Migrating from a hand-rolled route switch or an older router.
  • Route-level loading/error handling is missing or duplicated per component.

When NOT to use

  • Next.js App Router (see nextjs-architect).
  • A single-screen embed with no navigation.

Decision 1 — Router

Need Choice
Mature ecosystem, data APIs, framework mode React Router 7
Type-safe routes/params as a first-class feature TanStack Router
Full-stack TanStack (SSR + server functions) TanStack Start
Tiny SPA, no data loading React Router in declarative mode

Type-safety of params is the deciding axis for large route trees.

Decision 2 — Route tree = UI tree

  • Nested routes mirror nested layout; the outlet is the composition point.
  • Layout routes hold chrome only; they never fetch feature data.
  • Each route declares its own loader, errorElement, and pending UI.
  • 404 is a route, not a if (!found) return null.

Decision 3 — Data at the route, not in effects

  • Loaders fetch, routes render, components receive. No useEffect fetching on mount.
  • Actions own mutations; revalidate affected routes after they settle.
  • Parallel-load independent route data; defer only what is genuinely slow.
  • Params are parsed and validated at the route boundary (unknown in, typed out).

Decision 4 — Guards and auth

  • Client guards are UX; authorisation is enforced by the API.
  • Redirect logic lives in one place (route loader/guard), not in components.
  • Deep-link to a protected route must survive login and return to the target.

Decision 5 — Errors and boundaries per route

  • Attach an error element to each layout route; one global boundary hides which segment failed.
  • Pending states belong to the route (pendingComponent/loader state), not to a component-local spinner.
  • 404s are route-level: an unmatched path must render a real page, not a blank shell.

Failure modes

  • Route components that fetch, transform, and render business rules at once.
  • Duplicated loading state per component instead of route-level pending UI.
  • Query params read ad hoc inside components rather than through a typed hook.
  • Router state (location) copied into a store and kept in sync by effects.

Verification receipts

  1. Route tree printed: path, loader, error boundary, guard.
  2. Deep link to a nested route works on a cold load and after refresh.
  3. Forced loader failure renders the route's error boundary, not a blank page.
  4. Back/forward and param changes do not remount stable layouts.

04 同仓库更多 Skills

SriAkhilSJ
SriAkhilSJ/PulseAIRepo

interaction-patterns-architect

Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

design-system-ops-architect

Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

design-handoff-architect

Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

content-microcopy-architect

Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

ui-ux-implementation-architect

Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

test-strategy-architect

Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.

★ 0