T3 Cloudflare is a starter template for building a T3 Stack app (tRPC + Drizzle + Tailwind) that runs on Cloudflare Workers through OpenNext and uses Cloudflare D1 as its serverless SQLite database.
What is T3 Cloudflare?
T3 Cloudflare is a GitHub repository template that configures a T3 Stack app for deployment on Cloudflare's edge network. It takes a standard Next.js T3 app and adapts it to run on Cloudflare Workers using OpenNext, with D1 as the SQLite database. The template includes configuration files, scripts, and commands to create, migrate, and deploy both the database and the Worker. It is published by user exectx and is installable via the Cloudflare C3 CLI with the command pnpm create cloudflare@latest --template=exectx/t3-cloudflare.
Key Features
- OpenNext adapter — Runs a Next.js T3 app on Cloudflare Workers by using OpenNext to bundle the app for the Workers runtime.
- D1 database integration — Uses Cloudflare D1, a serverless SQLite database, with Drizzle ORM for schema definition and migrations.
- C3 CLI quickstart — Create a new project with the C3 CLI command shown above.
- Built-in migration scripts —
pnpm db:generateandpnpm db:migratehandle local D1 migrations;pnpm db:migrate:prodtargets remote D1 configured via.dev.vars. - D1 binding named DB — The Worker expects a D1 binding called
DB, which you create and configure inwrangler.jsonc. - Local development —
pnpm devruns the full stack locally;pnpm build,pnpm preview, andpnpm deployhandle staging and production. - Static asset support — The template includes handling for static assets, making it suitable for apps that serve frontend files from the Worker.
- Tailwind CSS styling — Tailwind is included as the styling solution, part of the standard T3 Stack combination.
Who should use T3 Cloudflare?
- Next.js developers who want to deploy T3 apps on Cloudflare Workers without managing the OpenNext configuration themselves.
- T3 Stack enthusiasts looking for a starter that already wires up tRPC, Drizzle, and Tailwind for the edge.
- Developers new to Cloudflare D1 who want a working reference for Drizzle migrations against local and remote D1 databases.
- OpenNext adopters who need a minimal example of serving a full-stack Next.js app from a Worker.
What can you do with T3 Cloudflare?
- Quickly scaffold a serverless full-stack app: Run the C3 CLI command to generate a new project with all dependencies and config in place, then start building routes with tRPC and Drizzle.
- Develop locally with a real D1 database: Use
pnpm devplus local D1 migrations to iterate on schema changes before deploying. - Deploy to Cloudflare's edge: Run
pnpm deployto push the Worker and D1 database to Cloudflare, with static assets served from the Workers runtime. - Manage schema changes across environments: Use the provided Drizzle Kit scripts to generate and apply migrations to both local and remote D1 instances.
How does T3 Cloudflare work?
- Create a project with the C3 CLI command.
- Install dependencies with
pnpm installand create a D1 database withpnpm wrangler d1 create DATABASE_NAME, then copy the returneddatabase_idintowrangler.jsonc. - Optionally copy
.dev.vars.exampleto.dev.varsto configure remote Drizzle commands. - Run
pnpm db:generateandpnpm db:migrateto create and apply local migrations, orpnpm db:migrate:prodfor remote D1. - Build, preview, and deploy with
pnpm build,pnpm preview, andpnpm deploy.
FAQ
Is T3 Cloudflare free?
Yes, the template itself is open source and free to use. Deploying to Cloudflare Workers and D1 has a free tier, but production usage may incur costs depending on Cloudflare's pricing for Workers requests and D1 storage.
What database does T3 Cloudflare use?
The template uses Cloudflare D1, a serverless SQLite database built into Cloudflare's network. Drizzle ORM is used to define schemas and generate migrations.
Does the template include authentication?
No, the template does not include authentication. It focuses on the core T3 Stack combination of tRPC, Drizzle, and Tailwind, so you would add your own auth provider like NextAuth or Lucia.
What is OpenNext?
OpenNext is an adapter that lets Next.js apps run on Cloudflare Workers. This template uses OpenNext to bundle the T3 app for the Workers runtime, enabling serverless deployment at the edge.
How do I change the D1 binding name?
The template expects a binding named DB. To change it, update the binding name in wrangler.jsonc and adjust the Worker code that references the D1 binding.








