Nextbase Docs
Nextbase Docs
HomeBlogWelcome to Nextbase v5!Choose your starterGetting startedLocal Supabase per agent
TanStack + Cloudflare D1InstallationEnvironment variablesAuthenticationAgent connectionsProject structureDeployment
AuthenticationWorkspaces and the admin area
Building with agentsEmails with Resend
TroubleshootingNextbase v5
The 8 starter kitsTanStack + Cloudflare D1

TanStack + Cloudflare D1

What the TanStack + Cloudflare D1 starter is, what it ships with, and what you need before you start.

This kit uses React Router on Cloudflare Workers with TanStack Query, D1, Drizzle and Better Auth. You get the account, workspace and project foundation, a separately deployed administrator app, and separate agent connections for users and application administrators.

Open the live demo · Repository

The stack

LayerWhat the kit uses
FrontendReact 19, React Router framework mode with streaming SSR, TanStack Query with a request-scoped query client, Tailwind CSS
ServerA Cloudflare Worker (apps/web/workers/app.ts) that runs the React Router loaders and actions, plus a second Worker for the administrator app (apps/admin/workers/app.ts)
DatabaseCloudflare D1 with a Drizzle schema and forward-only SQL migrations in apps/database
AuthenticationBetter Auth with email and password, verified email, magic links and optional Google, GitHub and Twitter sign-in
Background workA separate jobs Worker (apps/jobs) fed by a transactional outbox and a Cloudflare Queue, with a dead-letter queue and two cron schedules
Storage and realtimeTwo R2 buckets (public and private media) and Durable Objects for WebSocket invalidations and auth rate limiting
Email41 React Email templates, Resend in production and a D1 development inbox locally
Hosting used by the demoCloudflare Workers, with its D1 database and R2, Queue and Durable Object bindings

There is no Postgres, no Docker and no separate database server. Local development uses Wrangler's local D1 database inside the Worker runtime.

What you get out of the box

  • Accounts with sign-up, email verification, password reset, magic link login and optional social providers
  • Workspaces with owner, admin, member and readonly roles, invitations, onboarding and settings
  • Projects with comments, an approval state machine, audit events and realtime refreshes
  • A separate administrator app (apps/admin) on its own origin with users, workspaces, payments, CMS, feedback, settings and read-only impersonation
  • A User MCP on the web app and an Admin MCP on the admin app, so agents can read your app through OAuth connections
  • Stripe billing: catalog sync, webhooks, subscriptions, invoices and one-time Checkout
  • R2 media uploads with reservations, size and signature checks and cleanup jobs
  • AI SDK streaming chat with durable history and workspace credits
  • Marketing pages, compiled MDX docs with search, a blog and changelog CMS, roadmap and feedback boards
  • A public developer API (/api/v1/me) with Unkey API keys and an exact-origin CORS allowlist
  • Product analytics and scrubbed operational exception capture in D1
  • Vitest unit tests, Workers and Miniflare D1 integration tests, Playwright smoke tests, Oxlint and Oxfmt

The feature mapping from Nextbase Ultimate to this Cloudflare implementation is in docs/feature-parity.md in the repository. The administrator app is described in the "Separate administrator app" section of the repository README.md.

Prerequisites

RequirementDetail
Node.js24 or newer. The repository has a .nvmrc with 24 and engines.node is >=24.
pnpm11.1.2, pinned in the root package.json packageManager field. Run corepack enable and let Corepack pick it.
DockerNot needed. D1 runs locally through Wrangler.
Cloudflare accountOnly when you deploy. Local development needs no Cloudflare login.
Resend accountOptional locally. Without RESEND_API_KEY on the jobs Worker, emails land in the local D1 inbox. Needed for production email.
Stripe, OpenAI, Unkey, OAuth providersOptional. Billing, AI chat, API keys and social login stay off until you add their keys.

Workers-only runtime

Everything that handles a request runs in Cloudflare Workers. The repository's AGENTS.md asks you not to add Node-only runtime APIs to apps/web or apps/jobs.

Next steps

  1. Installation: clone, migrate the local D1 database and start the dev servers, including the admin app.
  2. Environment variables: every variable in the three .env.example files and the Wrangler vars.
  3. Authentication: Better Auth, roles, the trusted admin flow and what protects your data.
  4. Agent connections: the User MCP and Admin MCP endpoints and tools.
  5. Project structure: where routes, services, schema, jobs and tests live.
  6. Deployment: provisioning Cloudflare resources and deploying the three Workers.

For the shared concepts, read getting started and user and admin MCPs.

Deployment

Provision Cloudflare resources, configure production bindings and secrets, migrate D1 and deploy the web, admin and platform Workers of the Next.js + Cloudflare D1 starter.

Installation

Clone the TanStack + Cloudflare D1 starter, migrate the local D1 database, start the web, admin and jobs Workers and create your first account.

On this page

The stackWhat you get out of the boxPrerequisitesNext steps