Back to blog
engineering

TanStack Start vs Next.js: why I built my SaaS template on TanStack Start

By Daniel Chavez

I picked TanStack Start for WarpKit because I wanted end-to-end TypeScript safety, an app that's client-first where I opt into server code when I need it, and the freedom to host it wherever I want without the complexity of a server-first framework. Next.js makes the server the default, and after building five products on TanStack Start I don't miss anything from it.

Here's why I made that choice and what it looks like in a real codebase, with code from WarpKit.

How is TanStack Start different from Next.js?

In Next.js with the App Router, every component is a Server Component unless you mark it with 'use client'. So you start on the server and add boundaries wherever you need a click handler or some state, and I always found myself thinking about where that line was instead of about the feature.

TanStack Start goes the other way. The app is a normal React app that renders on the server first, and when I want code to run only on the server I write a server function and call it like any other function. That's the part I like most, because I always know where my code runs: if it's inside createServerFn it runs on the server, and everything else is the app.

What does a server function look like?

This is how WarpKit creates a note, trimmed a little:

export const createNoteFn = createServerFn({ method: 'POST' })
  .validator(noteInputSchema)
  .handler(async ({ data }) => {
    const user = await requireUser();
    if (!user) return err(ERROR_CODES.UNAUTHORIZED, 'Not authenticated');

    return withWriteLock(user.id, () => {
      const userDb = getUserDb(user.id);
      // ...
    });
  });

The input is checked with a Zod schema before the handler runs, and the type of data comes from that same schema, so the form that calls it gets an error in the editor if it sends the wrong shape. There's no API route to write and no fetch call to keep in sync with it.

What about types in the URL?

This is the one I'd miss the most if I went back. In TanStack Router the search params of a route have a schema too, so ?page=2&tag=sqlite is parsed and typed before the page sees it:

export const Route = createFileRoute('/_landing/blog/')({
  validateSearch: searchSchema,
  component: BlogIndex
});

A link to that page with a missing or wrong param doesn't compile, and route paths are typed the same way, so renaming a route shows me every link I broke. Next.js 16 can type a page's route params with PageProps, but search params still arrive as strings, and checking them was up to me.

And caching?

I never liked how many caching layers Next.js has, and its defaults keep changing, for example in Next.js 15 fetch went from cached by default to not cached. In WarpKit the data on the client goes through TanStack Query and the router's loaders, and I decide when something is stale, so what I see in development is what happens in production.

Where can you host it?

WarpKit runs as a plain Bun server, two workers on one box, so anything that runs a Bun process can run it. I deploy mine with RunMist on Hetzner servers that cost €5.99 a month, and the template's deployment docs also cover a plain Hetzner box with Caddy, Fly.io, Railway and Docker. I wanted out of Vercel because of the pricing and because the free plan doesn't allow commercial use, and with TanStack Start nothing in the code assumes where it runs.

Is TanStack Start fast to develop with?

It's built on Vite, Vite 8 in WarpKit today, and to be honest Vite is really fast, even on a codebase with 800 tests and 37 features.

Is there anything I miss from Next.js?

To be honest no. The Next.js ecosystem is bigger and there are more tutorials, which matters if you're learning, but for a SaaS where I want to know exactly what runs where and to host it cheaply, TanStack Start fits how I work. If you want to see a whole SaaS built on it, with billing, auth, an admin panel and a SQLite database per user, that's what WarpKit is. And if you want to see the rest of what I run my products on, hosting and email included, with what it costs me, I wrote that up on my own site.