Post

TanStack Start on Cloudflare Workers: The Full-Stack Stack Worth Watching

A deep dive into TanStack Start on Cloudflare Workers — what the stack looks like, how it compares to Next.js on a VPS, and why it's worth considering for your next project.

TanStack Start on Cloudflare Workers: The Full-Stack Stack Worth Watching

I’ve been running Next.js apps on a self-managed VPS — Docker containers behind Traefik, Dokploy for deployments, the whole stack. It works. But every time I spin up a new project, I’m asking the same question: do I really need to manage all this infrastructure for a web app?

That question led me down the TanStack Start + Cloudflare Workers rabbit hole. Here’s what I found.

What Is TanStack Start?

TanStack Start is a full-stack React framework built on TanStack Router and Vite. If you’ve used TanStack Query (formerly React Query), you already know the ecosystem’s philosophy: type-safe, explicit, no magic.

It’s currently at RC v1.154.0 — feature-complete and API-stable, approaching 1.0. Not bleeding edge anymore, but not as battle-tested as Next.js either.

The key difference from Next.js: TanStack Start doesn’t use React Server Components (RSC). Instead, it uses full-document SSR (Server-Side Rendering) with hydration, plus explicit server functions for mutations. There’s no mental model split between "use client" and "use server" — you get route-based loaders and server functions, and that’s it.

Why Cloudflare Workers?

Cloudflare Workers run on V8 isolates at the edge — over 300 Points of Presence (PoPs) globally. Every request is served from the nearest data center. No cold starts. No containers. No VPS to manage.

The pricing is hard to argue with:

  Workers ($5/mo plan) Typical VPS
Requests 10M/mo included Unlimited (but single location)
CPU 30M ms/mo included Dedicated cores
Bandwidth Free (no egress charges) Varies (AWS: $0.09/GB)
Scaling Automatic, global Manual, single datacenter
SSL/DDoS Built-in You configure it

That $5/month is per account, not per app. Deploy five apps and they share the same allowances. For comparison, a Hostinger KVM 4 runs $16/month, and that’s before you add managed database costs.

The Full Stack

Here’s what a TanStack Start project on Cloudflare actually looks like:

Layer Technology
Framework TanStack Start (Vite + TanStack Router)
Runtime Cloudflare Workers
Database Cloudflare D1 (or Neon PostgreSQL via Hyperdrive)
ORM Drizzle ORM
Auth Better Auth
Storage Cloudflare R2 (S3-compatible object storage)
KV Store Cloudflare KV
Error Tracking Sentry (@sentry/cloudflare SDK)

All of this is accessible through Cloudflare bindings — you declare what services you need in your Wrangler config, and they’re available in your Worker’s context. No connection strings, no network hops to co-located services.

Cloudflare D1: SQLite at the Edge

D1 is Cloudflare’s serverless database. It’s SQLite under the hood, which means:

  • Full SQL support — joins, indexes, transactions, all the standard stuff
  • 10 GB max per database — designed for horizontal scaling (many small databases) rather than one massive instance
  • Co-located with your Workers — queries don’t need a network round-trip to a separate database server
  • Time Travel — point-in-time recovery to any minute in the last 30 days, built in
  • Up to 50,000 databases per account — enables per-tenant database patterns

The trade-off: it’s SQLite, not PostgreSQL. No jsonb, no full-text search extensions, no LISTEN/NOTIFY. For most web apps and CRMs, SQLite handles everything you need. If you genuinely need PostgreSQL features, you can use Neon via Cloudflare Hyperdrive instead — it adds a network hop but keeps your PG schema.

Drizzle ORM works with both D1 and Neon, so your schema definitions and queries stay the same regardless of which database you choose.

Auth on the Edge

Better Auth works on Cloudflare Workers, but there’s one gotcha: D1 bindings are only available inside the request handler. You can’t initialize Better Auth at the module level like you would on Node.js. Instead, you use a factory function that creates the auth instance per-request.

There’s a better-auth-cloudflare package that handles this, plus a production-ready template that wires up TanStack Start + Better Auth + D1 together.

Observability

Sentry has an official @sentry/cloudflare SDK with Workers-specific features:

  • Automatic error/exception capture
  • D1 database instrumentation
  • Cron monitoring for scheduled Workers
  • Tracing and performance monitoring

For logs, you get three tiers:

  1. wrangler tail — real-time CLI log streaming (like docker logs -f)
  2. Dashboard Live Logs — same thing in the browser with filtering
  3. Workers Logs — persistent, queryable log storage with historical search

No Dozzle or external log aggregator needed. It’s all built into the platform.

TanStack Start vs Next.js

This is the part that matters if you’re deciding between the two for a new project.

Where TanStack Start Wins

Type safety goes deeper. Route params, search params, loaders, and server functions are all end-to-end type-safe. Next.js has improved here, but TanStack Router’s type inference is on another level — you get autocomplete on route params across your entire app.

The mental model is simpler. No RSC. No "use client" directives. No caching layer that sometimes does what you expect and sometimes doesn’t. You have route loaders that fetch data and server functions that mutate it. That’s the model.

Smaller client bundles. Public benchmarks show ~30-35% smaller client JS compared to Next.js. Less framework overhead means faster page loads.

Vite-based tooling. Faster dev server, better Hot Module Replacement (HMR), and access to the massive Vite plugin ecosystem. Next.js uses Turbopack which is fast but more locked-in.

Runtime-agnostic. Deploy to Cloudflare Workers, Node, Deno, Bun, Netlify, or Vercel. If you ever want to move off Cloudflare, you swap the deployment target, not the framework.

Where Next.js Still Wins

Ecosystem size. More tutorials, more Stack Overflow answers, more third-party integrations, more job postings. If you get stuck, there are more people who’ve solved the same problem.

Maturity. Next.js has years of production battle-testing. TanStack Start is RC — stable, but you’re an earlier adopter.

RSC for complex apps. If you’re building something where server components genuinely reduce client JS (heavy dashboards, content-heavy sites), RSC is a real advantage. TanStack Start sends the full component tree to the client.

You can also run Next.js on Workers. Via OpenNext, there’s an adapter that transforms Next.js build output to run on Cloudflare Workers. It’s a translation layer though — not native. TanStack Start targets Workers directly via Vite’s Cloudflare plugin with no adapter needed.

Deployments: Zero to Global in Seconds

This is where Cloudflare really shines compared to a VPS setup.

Deploying

1
wrangler deploy

That’s it. Your app is live globally in seconds. No Docker builds, no pushing to a container registry, no webhook triggers, no container restarts.

Gradual Rollouts

Instead of all-or-nothing deploys, Workers supports traffic splitting between versions:

  1. Deploy new version at 10% traffic
  2. Monitor errors and logs
  3. Bump to 50%, then 100%
  4. If something breaks, roll back instantly

Rollbacks

  • Automatic — Cloudflare can roll back when error rates spike
  • Manual — One click in the dashboard or wrangler rollback from CLI
  • Takes effect immediately, globally

Compare this to a VPS where you’d redeploy a previous Docker image tag and wait for the container to restart. Workers gives you zero-downtime gradual rollouts with automatic rollback out of the box.

What You Give Up

Moving to Workers isn’t free of trade-offs:

  • Worker limits — 30 seconds CPU time (paid plan), 128 MB memory. Heavy computation or long-running processes won’t work here.
  • No arbitrary services — You can’t run Typesense, Redis, or any custom binary. You’re limited to Cloudflare’s platform services (D1, KV, R2, Queues, Durable Objects).
  • D1 is single-threaded — Each database processes queries sequentially. Fine for CRUD apps, not great for analytics workloads.
  • 10 GB database cap — D1 databases max out at 10 GB each. You can create up to 50,000 of them, but a single massive database isn’t the pattern here.
  • TanStack Start is RC — API is stable, but you’re committing to a framework that hasn’t hit 1.0 yet.

Key Takeaways

  • TanStack Start + Cloudflare Workers is a compelling stack for new projects — type-safe routing, Vite DX, serverless deployment, and $5/month for your entire account
  • D1 handles most web app database needs — it’s SQLite, not PostgreSQL, but for CRUD-heavy apps the trade-off is worth it for co-located edge queries with zero config
  • The deployment story is the biggest upgradewrangler deploy with gradual rollouts and instant rollbacks beats managing Docker containers and reverse proxies
  • You don’t have to go all-in — You can run Next.js on Workers via OpenNext if you want the platform benefits without switching frameworks
  • Watch the maturity gap — Next.js has years of production hardening. TanStack Start is catching up fast but isn’t there yet. For a new side project or internal tool, that’s fine. For a production SaaS, evaluate carefully.

The stack I’d reach for on my next project: TanStack Start, Cloudflare Workers, D1, Drizzle ORM, Better Auth, and shadcn/ui. Same UI layer I’m already using, dramatically less infrastructure to manage.

Resources

This post is licensed under CC BY 4.0 by the author.