A minimal full-stack TypeScript template for building apps on Cloudflare Workers with tRPC, Hono, Drizzle ORM, and better-auth.
- Authentication: Username/password with better-auth, organization support
- API: Both Hono REST endpoints and tRPC
- Database: Drizzle ORM with D1 (SQLite)
- Type-safe: End-to-end type safety from database to frontend
- Runtime: Bun
- Backend: Cloudflare Workers + Hono
- API: tRPC (at
/api/trpc/*) - Database: Cloudflare D1 with Drizzle ORM
- Auth: better-auth
After creating your app from this template:
# Install dependencies
bun install
# Run the interactive setup CLI
bun run setupThe setup script will prompt for:
| Prompt | Example | What it replaces |
|---|---|---|
| Package scope prefix | my-org |
@coding-cowboys in all package.json names (e.g. @my-org/app-name) |
| App name | my-app |
app in wrangler, scripts, DB names |
| GitHub org or username | my-github-org |
palmithor in repo URLs (use your username if no org) |
| Display org name | My Org |
Pálmi Þór in LICENSE, headers |
| Display app name | My App |
Fjármál 1 in headers |
| Cloudflare workers subdomain | my-subdomain |
coding-cowboys in *.workers.dev URLs |
Press enter on any prompt to keep the template default.
-
Authenticate with Cloudflare
bunx wrangler login
-
Update the lockfile
bun install
-
Create a D1 database
bunx wrangler d1 create <your-app-name>
-
Update the
database_idinapps/worker/wrangler.jsonc -
Set the better-auth secret
bunx wrangler secret put BETTER_AUTH_SECRET
Add the following secrets in your GitHub repository settings (Settings > Secrets and variables > Actions):
CLOUDFLARE_API_TOKEN- Create an API token at Cloudflare Dashboard with "Edit Cloudflare Workers" permissionsCLOUDFLARE_ACCOUNT_ID- Found in Cloudflare Dashboard > Workers & Pages > Overview (right sidebar)CLOUDFLARE_WORKERS_SUBDOMAIN- Your workers subdomain (e.g.,your-subdomainfromyour-subdomain.workers.dev)
# Install dependencies
bun install
# Generate database migrations
bun db:generate
# Apply migrations locally
bun db:migrate
# Start development
bun run devMIT