Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
T3 Stack template for Cloudflare Workers using OpenNext, tRPC, Drizzle, and D1.
T3 Cloudflare is an open-source boilerplate that scaffolds a T3 Stack application — Next.js App Router, tRPC, Drizzle ORM, and Tailwind CSS — and configures it to run on Cloudflare Workers through OpenNext with Cloudflare D1 as the SQLite database.
T3 Cloudflare is a starter template for building full-stack TypeScript applications that deploy to Cloudflare's edge network. It takes a standard T3 Stack project and wires it for Cloudflare Workers via OpenNext, including a D1 binding named DB. The template is distributed as a GitHub template repository and can be scaffolded with the Cloudflare C3 CLI using the command pnpm create cloudflare@latest --template=exectx/t3-cloudflare. It uses pnpm as the package manager and requires wrangler for D1 and deployment tasks.
pnpm create cloudflare@latest --template=exectx/t3-cloudflare.pnpm build, pnpm preview, and pnpm deploy scripts for the full build-test-deploy cycle.DB; you create the database with pnpm wrangler d1 create and copy the returned database_id into wrangler.jsonc.pnpm db:generate and pnpm db:migrate for local SQLite, plus pnpm db:migrate:prod for applying migrations to remote D1 after configuring .dev.vars..dev.vars.example file is provided so you can set up local environment variables for running Drizzle commands against remote D1.pnpm dev) and preview of the production build.T3 Cloudflare suits developers who want to build on Cloudflare Workers with the conventions of the T3 Stack without manually wiring together OpenNext, D1, and Drizzle. Next.js developers moving to the edge can use this template as a reference configuration for App Router, tRPC, and D1. Teams that need a TypeScript, SQLite-backed REST or RPC API on Cloudflare get a pre-configured migration and deployment pipeline out of the box.
pnpm db:generate and pnpm db:migrate, then apply the same migrations to the production D1 database with pnpm db:migrate:prod after configuring .dev.vars.pnpm build and pnpm preview, then ship it to Cloudflare with pnpm deploy.The template uses OpenNext to build the Next.js app into a Cloudflare Worker, serving static assets alongside the server functions. Setting up a project follows the README steps: install dependencies with pnpm install, create a D1 database with pnpm wrangler d1 create, paste the resulting database_id into wrangler.jsonc, optionally copy .dev.vars.example to .dev.vars, then run pnpm dev for local development. Migrations are managed through Drizzle Kit, and deployment is a single pnpm deploy command.
It includes a full T3 Stack setup: Next.js with the App Router, tRPC for typed APIs, Drizzle ORM, Tailwind CSS, and Cloudflare-specific configuration for OpenNext, D1, and wrangler.
The template uses Cloudflare D1, a SQLite-based database at the edge. A D1 binding named DB is expected in the Worker configuration, and you create the database with pnpm wrangler d1 create.
Local D1 migrations use pnpm db:generate and pnpm db:migrate. For remote D1, ensure .dev.vars is configured, then run pnpm db:migrate:prod.
Run pnpm build to create the production build, pnpm preview to test it locally, and pnpm deploy to publish to Cloudflare Workers.
