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-routerand@react-router/devinpackage.jsonapp/routes.tsusingroute(),index()andlayout()helpersreact-router.config.tsand 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,metaand 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
app/routes.ts, the fastest way to see every URL- The route module for the page, starting with
loaderandaction react-router.config.ts, to know if the app is server-rendered or a static SPA
How a request moves through the code
- The URL is matched against
app/routes.ts. - Server
loaders run (orclientLoaders in the browser), in parallel for nested matches. - The component receives typed
loaderDatathrough its props. - Form submissions call the route
action, then loaders revalidate.
Questions to ask about the repository
- List every route from
routes.tswith the module that handles it. - Which routes use
clientLoaderinstead of a serverloader, 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.tsbefore assuming framework features exist. - Missing
+typesimports usually mean typegen hasn't run, not that the code is wrong.