How to understand a TanStack Start codebase
TanStack Start is a full-stack framework built on TanStack Router and Vite. Routes are files under `src/routes/` created with `createFileRoute`, data loads in route `loader`s, and server-only logic is called through type-safe server functions.
How to tell it's TanStack Start
@tanstack/react-start(or a solid variant) and@tanstack/react-routerinpackage.jsonsrc/routes/__root.tsxand route files callingcreateFileRoute- A generated
routeTree.gen.ts
Where things usually live
- src/routes/__root.tsx
- Root route: document, providers, global error handling.
- src/routes/**
- File-based routes;
$postId.tsxis a path param. - src/routeTree.gen.ts
- Generated route tree. Read-only; it is rebuilt from the files.
- src/server/ or *.functions.ts
- Server functions created with
createServerFn. - vite.config.ts
- The Start Vite plugin and its options.
Conventions, not rules. Real projects rename and move things, so confirm against the repository.
Where to start reading
__root.tsx- The route file and its
loader - The server functions that loaders and components call
How a request moves through the code
- The router matches the URL against the generated route tree.
- Route
beforeLoadhooks run (often for auth), thenloaders. - Loaders call server functions, which run on the server even when invoked from the browser.
- The component reads data with
Route.useLoaderData().
Questions to ask about the repository
- List the server functions and which routes call them.
- Where is auth enforced: in
beforeLoad, in server functions, or both? - Which search params are validated, and with what schema?
What trips people up
routeTree.gen.tschanges whenever routes change; don't review it line by line.- The framework has moved quickly, so API names in older posts may not match the installed version.