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

Keep server and browser responsibilities explicit. Validate server inputs, keep credentials on the server and use the supported deployment output for your hosting platform.

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?

Share one workflow and the outcome you want. We'll review your brief and suggest an appropriate next step; scope and deliverables are agreed before work begins.

Founder-led delivery · Existing systems first · Available internationally