A ready-to-code boilerplate with sensible defaults:
- Vite + React + TypeScript
- Tailwind (with a dark-mode palette + cyan accent)
- ESLint + Prettier
- React Router (SPA routing)
- Cloudflare Worker API under
/api(plus optional D1)
npm install
npm run devOpen http://localhost:3000.
npm run dev:full- Frontend:
http://localhost:3000 - Worker:
http://localhost:8787 - Vite proxies
/api/*to the local Worker - The SPA “API Demo” page lives at
/api-demo(Worker endpoints are under/api/*)
- Toggle cycles: System → Light → Dark
- Preference stored in
localStorageundertheme
GET /api/health→{ ok: true, now: string }POST /api/echo→ echoes JSON bodyGET /api/todos/POST /api/todos(optional, requires D1)
-
Uncomment the
[[d1_databases]]block inwrangler.tomlandwrangler.dev.toml. -
Create a database:
npx wrangler d1 create app-db
-
Run migrations:
npx wrangler d1 execute app-db --local --file=migrations/0001_schema.sql
npm run deploy:cf- Copy
.dev.vars.exampleto.dev.varsfor local Worker secrets. - Update
wrangler.tomlwith your project name and bindings.
| Command | Description |
|---|---|
npm run dev |
Vite dev server |
npm run dev:worker |
Worker dev server |
npm run dev:full |
Run Worker + Vite together |
npm run build |
Production build to dist/ |
npm run preview |
Preview dist/ locally |
npm run deploy:cf |
Deploy to Cloudflare |
npm run typecheck |
TypeScript typecheck |
npm run lint / lint:fix |
ESLint |
npm run format / format:check |
Prettier |
- Keep changes small and focused.
- Run
npm run lintandnpm run format:checkbefore opening a PR. - Update docs if behavior or commands change.
MIT