Skip to content
TanStack Start 2026-07-10 12 min

A Production Architecture for TanStack Start

Folder structure, data fetching, caching and server/client boundaries for a maintainable TanStack Start codebase.

By Mohammad Zayed

Overview

TanStack Start rewards a clear split between server and client code. The biggest wins come from moving data fetching into route loaders and server functions, rendering on the server, and shipping less JavaScript to the browser.

Folder structure

project tree
src/
  routes/
    __root.tsx
    index.tsx
    dashboard.tsx
  server/
    session.ts       # server functions
components/
  ui/
lib/
  db.ts
  auth.ts

Data fetching

src/routes/dashboard.tsx
export const Route = createFileRoute("/dashboard")({
  loader: async () => {
    return db.session.findMany({
      where: { userId: getUserId() },
      orderBy: { createdAt: "desc" },
      take: 20,
    });
  },
  component: () => {
    const sessions = Route.useLoaderData();
    return <SessionsTable data={sessions} />;
  },
});

Caching

Lean on the router's built-in loader caching and staleTime for repeated reads, and invalidate with router.invalidate() after writes. Measure cache hit rate before adding more layers.

Deployment

Deploy to a platform with edge or regional functions (Vercel, Cloudflare, or a Node host). Keep static marketing routes static and dynamic routes isolated.

Performance

Stream expensive parts with Suspense, and defer non-critical client JS.

FAQ

See the FAQ section above.

Frequently asked questions

How do I split server and client work in TanStack Start?
Do data loading in route loaders and server functions, and keep interactive UI in client components. This keeps your JS bundle small and your data on the server.
How should I handle auth in TanStack Start?
Read the session inside a server function or route beforeLoad guard, never ship secrets to the client, and gate routes with a shared guard.

Continue reading

Want help building this?

Book a free strategy call. We'll map your bottlenecks to the right systems and send a clear roadmap — even if we don't work together.

Chat on Telegram

Usually replies within minutes. Chat on Telegram: @northflowstudio

No obligation consultationFounder-led projectsInternational clientsFast responseSecure communication