Skip to content

How to understand a Remix codebase

Remix routes are modules that can export a `loader` (server data for GET), an `action` (server handling for form posts) and a default component. Nested routes render inside their parent's `<Outlet />`. Remix v2 was merged into React Router v7, so many Remix apps are mid-migration.

How to tell it's Remix

  • @remix-run/* packages in package.json
  • app/root.tsx and an app/routes/ folder with names like posts.$id.tsx and _index.tsx
  • Exports named loader, action and meta in route files

Where things usually live

app/root.tsx
The HTML document, global links, root loader and error boundary.
app/routes/
Flat routes: dots nest URLs (posts.$id.tsx is /posts/:id), _index is the index route, a leading _ makes a pathless layout.
app/entry.server.tsx
Server rendering entry; streaming and headers.
app/entry.client.tsx
Hydration entry in the browser.
app/models/ or app/*.server.ts
Server-only data access; the .server suffix keeps it out of the browser bundle.
vite.config.ts
The Remix Vite plugin and route config options.

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

Where to start reading

  1. app/root.tsx, for global data and layout
  2. The route file for the URL, starting with its loader and action
  3. *.server.ts modules, where database and session code usually lives

How a request moves through the code

  1. 1A request matches one or more nested routes from the file names.
  2. 2Remix runs every matched route's loader in parallel on the server.
  3. 3Components read loader data with useLoaderData and render; children appear inside <Outlet />.
  4. 4A <Form method="post"> submission calls the route's action on the server.
  5. 5After the action, Remix re-runs the loaders on the page so the UI shows fresh data.

Questions to ask about the repository

  • Map each URL to its route file and the loaders that run for it.
  • Where are sessions created and read?
  • Which actions write to the database, and what do they validate?
  • What would change if we migrated this app to React Router v7?

What trips people up

  • Flat-route file names encode the URL, so a dot or underscore in a file name is significant.
  • Code imported by a route module can leak into the browser bundle unless it lives in a .server file.
  • Error and catch boundaries are per route, so an error may render far from where it was thrown.