PluginBench
Skill
Pass
Audit score 90

react-router-framework-mode

remix-run/agent-skills

Build full-stack React applications with React Router's framework mode, file-based routing, and data loading.

What is react-router-framework-mode?

React Router framework mode provides a full-stack development experience with file-based routing, server-side and client-side rendering strategies, data loading via loaders, mutations via actions, and type-safe route APIs. Use this skill when configuring routes, handling forms and navigation, implementing pending UI states, or setting up authentication and rendering strategies.

  • Configure file-based routes with nested routing and dynamic segments
  • Load data server-side with loaders or client-side with clientLoader
  • Handle form submissions and mutations with actions or clientAction
  • Implement navigation with Link, NavLink, Form, and useNavigate
  • Build pending/optimistic UI states with useFetcher and loading indicators
  • Set up SSR, SPA mode, or pre-rendering via react-router.config.ts

How to install react-router-framework-mode

npx skills add https://github.com/remix-run/agent-skills --skill react-router-framework-mode
Prerequisites
  • React Router v7.0.0 or higher (v7.9.0+ for middleware support)
  • Node.js and npm installed
  • Basic understanding of React components and hooks
Claude Code
Cursor
Windsurf
Cline

How to use react-router-framework-mode

  1. 1.Install the skill using: npx skills add https://github.com/remix-run/agent-skills --skill react-router-framework-mode
  2. 2.Verify your React Router version with: npm list react-router
  3. 3.Load the relevant reference guide based on your task (routing.md, data-loading.md, actions.md, etc.)
  4. 4.Follow the critical patterns for forms (use Form method="get" for searches, useFetcher for inline mutations)
  5. 5.Place global UI like navigation and footer in root.tsx using Outlet for nested routes
  6. 6.Use loaderData in meta exports and implement error boundaries for error handling

Use cases

Good for
  • Building a search form that updates URL parameters without page navigation
  • Creating an inline favorite/star button that mutates data without full page reload
  • Setting up authentication with protected routes and session management
  • Configuring a multi-section app with global navigation and section-specific layouts
  • Implementing optimistic UI that shows changes immediately while server processes them
Who it's for
  • Full-stack React developers
  • Teams building server-rendered React applications
  • Developers migrating from traditional SPA patterns to framework mode
  • Anyone implementing complex routing, data loading, or form handling in React

react-router-framework-mode FAQ

When should I use Form vs useFetcher?

Use <Form> for page-level mutations that should navigate. Use useFetcher for inline mutations (like favoriting) that shouldn't cause page navigation. Search forms should use <Form method="get"> to update URL parameters.

What's the difference between loader and clientLoader?

loader runs on the server and can access databases/secrets safely. clientLoader runs in the browser and is useful for client-only data or when you want SPA-like behavior without server roundtrips.

How do I implement authentication with React Router framework mode?

Use the sessions reference to set up cookie-based sessions, then implement protected routes by checking authentication in loaders and redirecting unauthenticated users.

Do I need to create separate layout files for different sections?

No. Use nested routes for section-specific layouts. Global UI like navigation and footer belongs in root.tsx, not separate layout files.

What version of React Router do I need for middleware?

Middleware requires React Router v7.9.0 or higher with the v8_middleware flag enabled. Check your version with: npm list react-router

Full instructions (SKILL.md)

Source of truth, from remix-run/agent-skills.


name: react-router-framework-mode description: Build full-stack React applications using React Router's framework mode. Use when configuring routes, working with loaders and actions, handling forms, handling navigation, pending/optimistic UI, error boundaries, or working with react-router.config.ts or other react router conventions. license: MIT

React Router Framework Mode

Framework mode is React Router's full-stack development experience with file-based routing, server-side, client-side, and static rendering strategies, data loading and mutations, and type-safe route module API.

When to Apply

  • Configuring new routes (app/routes.ts)
  • Loading data with loader or clientLoader
  • Handling mutations with action or clientAction
  • Navigating with <Link>, <NavLink>, <Form>, redirect, and useNavigate
  • Implementing pending/loading UI states
  • Configuring SSR, SPA mode, or pre-rendering (react-router.config.ts)
  • Implementing authentication

References

Load the relevant reference for detailed guidance on the specific API/concept:

ReferenceUse When
references/routing.mdConfiguring routes, nested routes, dynamic segments
references/route-modules.mdUnderstanding all route module exports
references/special-files.mdCustomizing root.tsx, adding global nav/footer, fonts
references/data-loading.mdLoading data with loaders, streaming, caching
references/actions.mdHandling forms, mutations, validation
references/navigation.mdLinks, programmatic navigation, redirects
references/pending-ui.mdLoading states, optimistic UI
references/error-handling.mdError boundaries, error reporting
references/rendering-strategies.mdSSR vs SPA vs pre-rendering configuration
references/middleware.mdAdding middleware (requires v7.9.0+)
references/sessions.mdCookie sessions, authentication, protected routes
references/type-safety.mdAuto-generated route types, type imports, type safety

Version Compatibility

Some features require specific React Router versions. Always verify before implementing:

npm list react-router
FeatureMinimum VersionNotes
Middleware7.9.0+Requires v8_middleware flag
Core framework features7.0.0+loaders, actions, Form, etc.

Critical Patterns

These are the most important patterns to follow. Load the relevant reference for full details.

Forms & Mutations

Search forms - use <Form method="get">, NOT onSubmit with setSearchParams:

// ✅ Correct
<Form method="get">
  <input name="q" />
</Form>

// ❌ Wrong - don't manually handle search params
<form onSubmit={(e) => { e.preventDefault(); setSearchParams(...) }}>

Inline mutations - use useFetcher, NOT <Form> (which causes page navigation):

const fetcher = useFetcher();
const optimistic = fetcher.formData?.get("favorite") === "true" ?? isFavorite;

<fetcher.Form method="post" action={`/favorites/${id}`}>
  <button>{optimistic ? "★" : "☆"}</button>
</fetcher.Form>;

See references/actions.md for complete patterns.

Layouts

Global UI belongs in root.tsx - don't create separate layout files for nav/footer:

// app/root.tsx - add navigation, footer, providers here
export default function App() {
  return (
    <div>
      <nav>...</nav>
      <Outlet />
      <footer>...</footer>
    </div>
  );
}

Use nested routes for section-specific layouts. See references/routing.md.

Route Module Exports

meta uses loaderData, not deprecated data:

// ✅ Correct
export function meta({ loaderData }: Route.MetaArgs) { ... }

// ❌ Wrong - `data` is deprecated
export function meta({ data }: Route.MetaArgs) { ... }

See references/route-modules.md for all exports.

Further Documentation

If anything related to React Router is not covered in these references, you can search the official documentation:

https://reactrouter.com/docs