React router best practices
Skill lazuee/agent-skills/skills/react-router-best-practices
Build applications with React Router in Framework, Data, Declarative, and unstable RSC modes. Use when configuring routes, route modules, loaders, actions, forms, fetchers, navigation, pending UI, SSR/SPA/pre-rendering, middleware, URL params/search params, or React Router upgrades.From its SKILL.md
npx -y skills add lazuee/agent-skills --skill react-router-best-practicesAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.8 KB, 607 tokens by cl100k_base, as published. Nobody here has run it
React Router Best Practices
Conventions for working with React Router across its four modes. Contains 5 rules in 4 categories. Before changing an app, identify the mode, load the matching rule, then read the installed docs for the installed package version.
When to Apply
- Configuring or editing routes in a React Router app
- Adding data loading (loaders) or mutations (actions) to routes
- Working with forms, fetchers, or pending UI
- Setting up SSR, SPA mode, or pre-rendering
- Migrating between React Router modes
- Debugging route matching, revalidation, or navigation issues
Rules Summary
Detection (CRITICAL)
identify-mode-first - @rules/identify-mode-first.md
Before changing a React Router app, identify Framework, Data, or Declarative mode from dependencies and config files. Applying patterns from the wrong mode produces code that won't compile.
Documentation (HIGH)
use-installed-docs - @rules/use-installed-docs.md
Read node_modules/react-router/docs/ for version-accurate guidance. Each doc includes a [MODES: ...] marker — only apply docs that match the app's mode.
Patterns (HIGH)
route-configuration - @rules/route-configuration.md
Framework uses route modules with typed exports from ./+types/<route>. Data uses route object arrays. Declarative uses JSX <Routes>/<Route>. Do not mix patterns across modes.
data-loading-conventions - @rules/data-loading-conventions.md
Load data with loader, mutate with action. Use <Form> for navigation mutations, useFetcher for same-page mutations. Don't bypass these with useEffect fetching.
Migration (MEDIUM)
mode-migration - @rules/mode-migration.md
If the user's mode doesn't support a feature (e.g., pending UI in Declarative), recommend migrating to Data or Framework Mode. Don't build workarounds.
Mode Detection Quick Reference
| Mode | Key Signals |
|---|---|
| Framework | @react-router/dev, react-router.config.ts, app/routes.ts, ./+types/... |
| Data | createBrowserRouter, <RouterProvider>, route object arrays |
| Declarative | <BrowserRouter>, <Routes>, <Route element={...}> |
| RSC | unstable_reactRouterRSC, @vitejs/plugin-rsc, unstable_RSCRouteConfig |
Philosophy
- Mode-first — Identify the mode before writing any code
- Docs-driven — Read installed docs, not memory
- No mixing — Each mode has its own patterns; don't cross the streams
- Migrate, don't hack — If a mode lacks a feature, recommend upgrading
What ships with it: 5 files
13.9 KB alongside SKILL.md
rules/
- data-loading-conventions.md3.3 KB
- identify-mode-first.md2.9 KB
- mode-migration.md2.4 KB
- route-configuration.md3.2 KB
- use-installed-docs.md2.0 KB