A Hono + Cloudflare Workers + D1 template for fast prototyping.
These steps cannot be completed automatically by AI.
Configure the same credential set in both places:
- GitHub Actions secrets in the new repository:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_IDADMIN_PASSWORD
- Permanent environment variables on your local machine:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_IDADMIN_PASSWORD
This template intentionally uses the same variable names locally and in GitHub so development and deployment do not drift into separate configuration schemes.
- The repository name, folder name, and Worker name are all treated as
[project-name] - The D1 database name is always
[project-name]-prod - The deployment URL is
https://[project-name].<your-workers-dev-subdomain>.workers.dev npm run sync:projectsyncs naming intopackage.json,wrangler.jsonc, andsrc/project.ts
- Anyone can open the dev page
- Reading and modifying todo data requires login
- The initial username is always
admin - The initial password comes from the Worker secret
ADMIN_PASSWORDin deployed environments, and from the localADMIN_PASSWORDenvironment variable during local development - The app still supports lazily creating the
adminuser on the first successful login using the currentADMIN_PASSWORD - Every GitHub Actions deploy syncs both the remote Worker secret and the remote D1
adminpassword to the latestADMIN_PASSWORD - If you change
ADMIN_PASSWORDlocally, runnpm run db:reset:localor update that user's password manually - Authentication is database-backed, with users and sessions stored in D1 for future extension
First configure CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID, and ADMIN_PASSWORD as permanent environment variables on your system, then run:
npm install
npm run db:reset:local
npm run devdb:reset:local rebuilds the local Wrangler D1 database from scratch and reapplies migrations. It is the preferred way to start fresh locally or let AI reset the local database safely.
npm test
npm run typecheckAfter you push or merge to main, the deploy workflow will:
- Check that
CLOUDFLARE_API_TOKEN,CLOUDFLARE_ACCOUNT_ID, andADMIN_PASSWORDall exist as Actions secrets, and fail immediately with the missing secret name if any are absent - Install dependencies
- Sync the project name
- Run type checking and tests
- Ensure the remote D1 database
[project-name]-prodexists - Upload the Worker secret
ADMIN_PASSWORD - Run remote migrations
- Sync the remote D1
adminpassword to the latestADMIN_PASSWORD - Deploy the Worker
The template ships with a minimal working page that:
- Uses the D1
todostable - Includes basic HTML, CSS, and JS
- Supports login
- Supports creating todos
- Supports toggling completion status
npm run sync:project
npm run db:reset:local
npm run db:migrate:remote
npm run db:ensure:remote
npm run dev
npm test