react-router-v7
Skill275 starsChanged 35 days agoApache-2.0View on GitHub
React Router v7 framework mode conventions for route modules, data loaders, actions, and progressive enhancement. Use when building file-based routes with loaders/actions, handling form submissions with Form/useFetcher/useSubmit, adding route ErrorBoundary components, revalidating data after mutations, or migrating Remix-style route modules to React Router v7.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- stonegiantstudio/skillstheir own version, first seen Sep 29, 2026
- robiparvez/claude-code-guidelinestheir own version, first seen Aug 7, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- stonegiantstudio/skills★ 3same name
- robiparvez/claude-code-guidelines★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository264 other files it gives its agents.
- accessibility-a11ySkill
- alpine-jsSkill
- analytics-data-analysisSkill
- android-developmentSkill
- angular-developmentSkill
- angularSkill
- anime-jsSkill
- anthropic-claude-developmentSkill
- api-developmentSkill
- apollo-graphqlSkill
- aspnet-coreSkill
- astroSkill
- auth0-authenticationSkill
- autogen-developmentSkill
- automl-hyperparameter-optimizationSkill
- aws-developmentSkill
- azureSkill
- backend-developmentSkill
- bash-scriptingSkill
- beautifulsoup-parsingSkill
- bitbucket-workflowSkill
- blazorSkill
- blender-python-addonSkill
- blockchainSkill
- bootstrapSkill
- business-central-developmentSkill
- cheerio-parsingSkill
- chrome-extension-developmentSkill
- ci-cd-best-practicesSkill
- clean-architectureSkill
- clean-codeSkill
- clerk-authenticationSkill
- cloudflare-developmentSkill
- computer-vision-opencvSkill
- convexSkill
- cppSkill
- c-sharpSkill
- cssSkill
- cypressSkill
- data-analysis-jupyterSkill
- data-analystSkill
- data-jupyter-pythonSkill
- deep-learning-pythonSkill
- deep-learning-pytorchSkill
- deep-learningSkill
- deno-typescriptSkill
- design-systemsSkill
- devopsSkill
- django-pythonSkill
- django-rest-api-developmentSkill
- dockerSkill
- dotnetSkill
- drizzle-ormSkill
- drupal-developmentSkill
- elasticsearch-best-practicesSkill
- electron-developmentSkill
- elixirSkill
- embedded-stm32Skill
- esbuild-bundlerSkill
- ethereumSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 5 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Use route modules as the boundary for route UI, loader data, actions, metadata, and error boundaries — a route module is the unit of code …
- Very specific: line 26
Keep route modules small; move shared UI to app/components/ and reusable data access to a services layer (e.g.
- Very specific: line 27
Prefer file-based routing in framework mode when the project is configured for it.
- Very specific: line 28
Use nested routes for shared layouts and progressive disclosure — a parent route's <Outlet /> renders the matched child.
- Distinctive: line 82
Use loaders for route data that should be available before render — this avoids loading spinners for data the page can't function without.
- Distinctive: line 83
Keep loaders deterministic and side-effect free.
- Very specific: line 86
Use deferred or streaming patterns (defer, or returning promises for <Await>) only when they measurably improve perceived performance — not …
- Very specific: line 90
Use actions for route mutations and form submissions.
- Very specific: line 91
Prefer <Form>, useFetcher, and useSubmit for progressive enhancement — these work without client-side JavaScript and layer on optimistic UI …
- Very specific: line 94
Keep server-only secrets and privileged operations (API keys, direct DB writes) out of client actions — perform them in .server.ts modules …
- Very specific: line 116
Keep ephemeral UI state (open/closed dropdown, hover state) local to components with useState.
- Very specific: line 117
Use pending navigation state (useNavigation(), fetcher.state) to show optimistic or loading UI instead of a separate global spinner store.
- Very specific: line 118
Avoid global state (Redux/Zustand/Context) for data that belongs to route loaders — it duplicates the router's own cache and goes stale.
- Distinctive: line 123
Add tests for route loaders, actions, validation failures, and error boundaries as isolated units, independent of full component rendering.
- Distinctive: line 124
Use integration tests (e.g.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Router v7
React Router v7 framework mode unifies routing, data loading, and mutations into route modules, each exporting a loader, action, default component, and ErrorBoundary for a single URL segment.
Workflow for Building a Route Module
- Create the route file — Add a file under
app/routes/(or your configured routes directory) for the URL segment, using nested folders/files for layouts and dynamic segments. - Export a loader — Fetch the data the route needs before render; validate route params and search params at the top of the loader.
- Export a component — Read loader data via
useLoaderData()and render UI; keep the component focused on presentation. - Export an action — Handle
POST/PUT/DELETEsubmissions from<Form>oruseFetcher; return typed data (including validation errors) instead of throwing for expected failures. - Export an ErrorBoundary — Handle thrown errors (400s, 500s, unexpected exceptions) locally so one route's failure doesn't take down the whole app.
- Wire up navigation — Use
<Form>,useFetcher, anduseSubmitfor mutations so the app works with JavaScript disabled and gets optimistic UI when it's enabled. - Test the module — Write tests for the loader, action, validation failures, and error boundary independently of the rendered component tree.
Route Modules
- Use route modules as the boundary for route UI, loader data, actions, metadata, and error boundaries — a route module is the unit of code splitting and data loading.
- Keep route modules small; move shared UI to
app/components/and reusable data access to a services layer (e.g.app/services/posts.server.ts). - Prefer file-based routing in framework mode when the project is configured for it; use the explicit
routes.tsconfig for advanced/dynamic route trees. - Use nested routes for shared layouts and progressive disclosure — a parent route's
<Outlet />renders the matched child. - Export route-specific
ErrorBoundarycomponents for recoverable route failures instead of relying on a single app-wide boundary.
// app/routes/posts.$postId.tsx
import { Form, useLoaderData, useNavigation } from "react-router";
import type { Route } from "./+types/posts.$postId";
import { getPost, updatePost } from "~/services/posts.server";
export async function loader({ params }: Route.LoaderArgs) {
const post = await getPost(params.postId);
if (!post) {
throw new Response("Not Found", { status: 404 });
}
return { post };
}
export async function action({ request, params }: Route.ActionArgs) {
const formData = await request.formData();
const title = String(formData.get("title") ?? "");
if (title.trim().length === 0) {
return { ok: false as const, errors: { title: "Title is required" } };
}
await updatePost(params.postId, { title });
return { ok: true as const, errors: null };
}
export default function PostDetail() {
const { post } = useLoaderData<typeof loader>();
const navigation = useNavigation();
const isSubmitting = navigation.state === "submitting";
return (
<Form method="post">
<input name="title" defaultValue={post.title} />
<button type="submit" disabled={isSubmitting}>
{isSubmitting ? "Saving..." : "Save"}
</button>
</Form>
);
}
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
if (error instanceof Response && error.status === 404) {
return <p>Post not found.</p>;
}
return <p>Something went wrong loading this post.</p>;
}Data Loading
- Use loaders for route data that should be available before render — this avoids loading spinners for data the page can't function without.
- Keep loaders deterministic and side-effect free; a loader should read data, not write it.
- Validate params and search params at the loader boundary (e.g. parse and range-check a
pagequery param) rather than trusting them downstream. - Return typed data and consume it through
useLoaderData<typeof loader>()rather than duplicating fetch logic in the component. - Use deferred or streaming patterns (
defer, or returning promises for<Await>) only when they measurably improve perceived performance — not by default.
Mutations
- Use actions for route mutations and form submissions; an action runs on
POST/PUT/PATCH/DELETEnavigations and fetcher submissions to that route. - Prefer
<Form>,useFetcher, anduseSubmitfor progressive enhancement — these work without client-side JavaScript and layer on optimistic UI when it's available. - Revalidate affected loader data after mutations; React Router automatically revalidates loaders on the current route tree after an action completes, so avoid manually refetching in
useEffect. - Handle validation errors as typed action data (
return { errors }) instead of throwing generic exceptions — reserve thrownResponses for actual HTTP-status failures (404, 401, 500). - Keep server-only secrets and privileged operations (API keys, direct DB writes) out of client actions — perform them in
.server.tsmodules that are stripped from the client bundle.
// Optimistic UI with useFetcher
function LikeButton({ postId, liked }: { postId: string; liked: boolean }) {
const fetcher = useFetcher();
const optimisticLiked = fetcher.formData
? fetcher.formData.get("liked") === "true"
: liked;
return (
<fetcher.Form method="post" action={`/posts/${postId}/like`}>
<input type="hidden" name="liked" value={String(!optimisticLiked)} />
<button type="submit">{optimisticLiked ? "Unlike" : "Like"}</button>
</fetcher.Form>
);
}Navigation and State
- Store shareable state in URL params or search params (filters, pagination, selected tab) so links and reloads reproduce the same view.
- Keep ephemeral UI state (open/closed dropdown, hover state) local to components with
useState. - Use pending navigation state (
useNavigation(),fetcher.state) to show optimistic or loading UI instead of a separate global spinner store. - Avoid global state (Redux/Zustand/Context) for data that belongs to route loaders — it duplicates the router's own cache and goes stale.
TypeScript and Testing
- Type loader and action return values; use the generated
Route.LoaderArgs/Route.ActionArgstypes (from./+types/<route>) for full inference of params and return types. - Add tests for route loaders, actions, validation failures, and error boundaries as isolated units, independent of full component rendering.
- Use integration tests (e.g. Playwright, Testing Library with a router harness) for critical form and navigation flows.
- Mock network and persistence at the route-service boundary (
app/services/*.server.ts) rather than mockingfetchdeep inside components.
Common Mistakes
- Duplicating loader fetches in
useEffect— this causes a loading waterfall and defeats the purpose of route-level data loading. - Mutating data directly inside a loader — loaders can run multiple times (revalidation, prefetch) and must stay read-only.
- Hiding route errors behind a single generic app-level catch-all
ErrorBoundaryinstead of route-scoped boundaries that preserve navigation and layout. - Putting auth checks only in components (e.g. redirecting from a
useEffect) when the underlying loader data is protected — check and redirect inside the loader itself so no protected data is ever fetched or flashed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

