Skip to content

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-router in package.json
  • src/routes/__root.tsx and route files calling createFileRoute
  • 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.tsx is 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

  1. __root.tsx
  2. The route file and its loader
  3. The server functions that loaders and components call

How a request moves through the code

  1. 1The router matches the URL against the generated route tree.
  2. 2Route beforeLoad hooks run (often for auth), then loaders.
  3. 3Loaders call server functions, which run on the server even when invoked from the browser.
  4. 4The 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.ts changes 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.