Skip to content

How to understand a React Router v7 (framework mode) codebase

React Router v7 can be used as a full framework, the successor to Remix. Routes are declared in `app/routes.ts`, route modules export `loader`, `action` and a component, and type generation writes a `+types` file for each route so loader data is typed end to end.

How to tell it's React Router v7 (framework mode)

  • react-router and @react-router/dev in package.json
  • app/routes.ts using route(), index() and layout() helpers
  • react-router.config.ts and imports like ./+types/product

Where things usually live

app/routes.ts
The route table: which module serves which URL, and how they nest.
app/root.tsx
Document layout, root loader, error boundary.
app/routes/*.tsx
Route modules exporting loader, action, clientLoader, meta and the component.
.react-router/types/
Generated route types. Don't edit; they are rebuilt by typegen.
react-router.config.ts
SSR on or off, prerendering, app directory.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. app/routes.ts, the fastest way to see every URL
  2. The route module for the page, starting with loader and action
  3. react-router.config.ts, to know if the app is server-rendered or a static SPA

How a request moves through the code

  1. 1The URL is matched against app/routes.ts.
  2. 2Server loaders run (or clientLoaders in the browser), in parallel for nested matches.
  3. 3The component receives typed loaderData through its props.
  4. 4Form submissions call the route action, then loaders revalidate.

Questions to ask about the repository

  • List every route from routes.ts with the module that handles it.
  • Which routes use clientLoader instead of a server loader, and why?
  • Is server rendering enabled, and which routes are prerendered?

What trips people up

  • The same package also runs in plain library mode, so check for routes.ts before assuming framework features exist.
  • Missing +types imports usually mean typegen hasn't run, not that the code is wrong.