Sandbox
@knowsuchagency/cloudflare-template

Copier template for Cloudflare Worker auth apps

This template generates a Cloudflare Worker app with Better Auth mounted at `/api/auth/*`, a shadcn/ui login SPA, and Cloudflare D1 backing the auth tables. It also renders the Worker config, Drizzle schema, and app files so you begin with a complete auth project rather than a blank folder.

2 stars0 forksTypeScriptUpdated 2mo ago
Who it's for

Builders who want to generate a Cloudflare auth project with a Worker, a login SPA, and D1.

What it delivers

You can start from a working auth app scaffold instead of wiring the Worker, database, and UI yourself.

What it does

Worker auth endpoint

Generates a Hono Worker with Better Auth mounted at `/api/auth/*` and a `drizzle-orm/d1` adapter.

Login SPA

Includes a Vite React app with a shadcn/ui login screen, radix-lyra, and phosphor icons, served through the Worker assets binding.

D1 schema and migration

Creates the Drizzle schema and SQL migration for the Better Auth tables: user, session, account, and verification.

Cloudflare config

Renders `wrangler.jsonc` with the D1 binding, SPA fallback, and `run_worker_first` routing for API paths.

Self-hosting guides

Documents escape hatches for moving the database, runtime, or object storage off Cloudflare when needed.

How to get it

  1. 1Run
    uvx copier copy gh:<owner>/<this-repo> ./my-auth-app
    # or from a local checkout:
    uvx copier copy path/to/this-template ./my-auth-app

README

cloudflare-better-auth-d1 (copier template)

Copier template for a Cloudflare Worker that serves Better Auth + a shadcn/ui login SPA, backed by Cloudflare D1.

Generated projects contain:

  • Hono Worker with Better Auth mounted at /api/auth/*, drizzle-orm/d1 adapter
  • Vite React SPA (shadcn preset buFznsW, radix-lyra, phosphor icons) served via the Worker's assets binding
  • Generated drizzle schema + SQL migration for the four better-auth tables (user, session, account, verification)
  • wrangler.jsonc with D1 binding, SPA fallback, and run_worker_first: ["/api/*"]

Usage

uvx copier copy gh:<owner>/<this-repo> ./my-auth-app
# or from a local checkout:
uvx copier copy path/to/this-template ./my-auth-app

You'll be asked for:

  • project_slug — kebab-case name for the Worker and package
  • app_title / app_tagline — text shown in the login card
  • worker_name / d1_database_name — defaults derived from project_slug

Post-generation, copier runs bun install, cd web && bun install && bun run build, and wrangler types. Follow the message printed afterwards to create the D1 database and deploy.

Self-hosting strategy

The default rendered project is vanilla Cloudflare + D1 — right for ~90% of projects. When it isn't, a rendered project can move selected pieces (DB, object storage, runtime) onto your own infra without a rewrite. docs/ documents each escape hatch:

Each doc describes the pattern, trade-offs, and order of operations, and links to the working reference in knowsuchagency/vpc-test for the drop-in files. See docs/README.md for the decision framework (when to reach for each).

Developing this template

The template source lives under template/. Files ending in .jinja are rendered; everything else is copied verbatim.

Regenerate into a scratch dir to smoke-test:

uvx copier copy --trust . /tmp/smoke-test --data project_slug=smoke-test

Files in the repo

Repository payload7 top-level entries
  • docs
  • template
  • .gitignore
  • AGENTS.md
  • CLAUDE.md
  • copier.yml
  • README.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More templates

CopilotKit/
OpenBot

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

4.6k
Donchitos/
Claude-Code-Game-Studios

Turn Claude Code into a full game dev studio — 49 AI agents, 72 workflow skills, and a complete coordination system mirroring real studio hierarchy.

25k

A self-organizing Obsidian vault that gives AI coding agents persistent memory. Claude Code, Codex CLI, Gemini CLI.

4.6k
idavidov13/
agentic-playwright

Production-grade Playwright + TypeScript Scaffold for Agentic Testing. Harness for all major AI coding agents baked in.

163
gavishap/
omnia-vault

Omnia Vault - the all-in-one project brain: an Obsidian LLM wiki, Graphify code graphs, a living plan that triages new videos against itself, and a Claude Code ⇄ Codex relay. Everything your project knows, in one clonable vault.

60

🎬 Tạo video "so sánh kiến thức" ngắn tự động — HyperFrames + AI voice, 1 template nhiều chủ đề.

169