Saasflare Starter is an opinionated Full Stack Starter Kit built for Cloudflare's Edge Network. It runs TanStack Start (Frontend) and Hono (Backend) as independent Workers connected by End-to-End Type Safety. Forget complex configuration, deploy globally with a single command. Runs for $0/month.
- Zero Cost: Runs 100% on Cloudflare (Workers + D1). $0/month for most hobby/startup apps.
- End-to-End Type Safety: Shared Zod schemas + ORPC. Frontend calls backend like a local function.
- Infrastructure from Code: Powered by Alchemy.run. No
wrangler.toml. Just TypeScript. - AI-First Workflow: Optimized for LLMs. Includes GEMINI.md context file for instant agent onboarding.
- Prompt Example: "Read GEMINI.md, then create a todos table and expose a getTodos API."
| Category | Technology | Description |
|---|---|---|
| Frontend | TanStack Start | Edge-optimized React framework. |
| Backend | Hono | Ultra-fast standard web framework. |
| Communication | ORPC + TanStack Query | E2E Type-safe RPC |
| Database | Cloudflare D1/KV | Serverless SQLite at the edge. |
| ORM | Drizzle ORM | Lightweight, type-safe SQL ORM. |
| UI | Tailwind V4 + Shadcn | Modern, accessible styling. |
| Infrastructure | Alchemy.run | TypeScript-based IaC. |
| Linting | Biome | Fast linting and formatting. |
starter/
├── apps/
│ ├── server/ # Hono Server Worker
│ └── web/ # TanStack Start Frontend Worker (port 3000)
└── packages/
├── api/ # Shared ORPC API definitions & Zod schemas
├── db/ # Drizzle Schema & Migrations
├── ui/ # Shared Shadcn UI components
└── config/ # Shared TS configs
New here? Follow the full tutorial — docs/quickstart.md walks from "Use this template" through your first manual deploy to multi-environment CI auto-deploy, including the required auth env.
- Node.js (v23.6+ — the project runs
.tsfiles directly via Node) - pnpm (
npm i -g pnpm) - Cloudflare Account
Clone the repo and install dependencies.
git clone https://github.com/saasflare-dev/starter.git
cd starter
pnpm installBoth apps launch with --env-file .local.env and fail to start if that file is
missing, so create both before the first run. Empty files are fine —
alchemy dev --stage local hardcodes http://localhost:3000 / :4000 for
CORS and the client bundle, and every other value has a working local default.
cp apps/server/.local.env.example apps/server/.local.env
cp apps/web/.local.env.example apps/web/.local.env
pnpm dev
.local.envis for local dev only..dev.env/.prod.envare for stage deploys (CI-injected).
Authenticate with Cloudflare to grant deployment permissions.
pnpm alchemy configure
pnpm alchemy loginDeploy everything to Cloudflare's global network.
# Deploy to Dev
pnpm run deploy:dev
# Deploy to Prod
pnpm run deploy:prodOne-shot deploy. URLs are resolved automatically inside
alchemy.run.ts(viacomputeWorkerDevDomain), soNEXT_PUBLIC_SERVER_URLandCORS_ORIGINnever need to be filled in by hand —deploy:dev/deploy:prodwork first time. Control-plane credentials live in.alchemy.envat the repo root; per-app deploy config (optionalWEB_DOMAIN/SERVER_DOMAIN, auth, R2 keys) lives inapps/{server,web}/.{stage}.env. See docs/deploy.md for the full runbook.
This project ships two GitHub Actions workflows:
deploy.yml— push todev→ deploys to the Development environment (starter-web-dev.<account>.workers.dev); push tomain→ deploys to Production (starter-web-prod.<account>.workers.dev).preview.yml— every PR opened againstdevormaingets its own isolated stage (pr-<N>) with its own Worker, KV, D1, R2. A bot comment on the PR posts the preview URLs. Closing the PR auto-destroys the stage.
The workflows read exactly five Repository Secrets (Settings -> Secrets and variables -> Actions -> New repository secret). Each is the full content of a local env file, which CI writes back to its original path before deploying:
| Secret | Local file | Contents |
|---|---|---|
ENV_ALCHEMY |
.alchemy.env |
Control-plane credentials (CLOUDFLARE_API_TOKEN, ALCHEMY_STATE_TOKEN). Required — Actions cannot run the interactive alchemy login. |
ENV_SERVER_DEV / ENV_SERVER_PROD |
apps/server/.dev.env / .prod.env |
Server Worker config |
ENV_WEB_DEV / ENV_WEB_PROD |
apps/web/.dev.env / .prod.env |
Web deploy config |
There is no standalone CLOUDFLARE_API_TOKEN or ALCHEMY_STATE_TOKEN repository secret — those travel inside ENV_ALCHEMY. See .alchemy.env.example for how to generate them.
Or use the helper script (skips missing files with a warning):
pnpm sync:secretsManual equivalent:
gh secret set ENV_ALCHEMY < .alchemy.env
gh secret set ENV_SERVER_DEV < apps/server/.dev.env
gh secret set ENV_SERVER_PROD < apps/server/.prod.env
gh secret set ENV_WEB_DEV < apps/web/.dev.env
gh secret set ENV_WEB_PROD < apps/web/.prod.envMIT © Saasflare
Saasflare Starter 是一套有主见(Opinionated)的全栈 Starter Kit,专为 Cloudflare 边缘网络打造。它将 TanStack Start(前端)和 Hono(后端)作为独立的 Worker 运行,并通过端到端(End-to-End)类型安全进行连接。告别繁琐配置,一条命令全球部署。运行成本 $0/月。
- 零成本: 100% 运行在 Cloudflare (Workers + D1) 上。绝大多数个人项目/初创应用 $0/月。
- 端到端类型安全: 共享 Zod Schema + ORPC。前端调用后端就像调用本地函数一样。
- 基础设施即代码: 由 Alchemy.run 驱动。告别
wrangler.toml。只写 TypeScript。 - AI 优先工作流: 为 LLM 优化。内置 GEMINI.md 上下文文件,AI 助手开箱即用。
- Prompt 示例: "阅读 GEMINI.md,然后在创建 todos 表并暴露一个 getTodos API。"
| 类别 | 技术 | 描述 |
|---|---|---|
| Frontend | TanStack Start | 针对边缘优化的 React 框架。 |
| Backend | Hono | 超快的 Web 标准框架。 |
| Communication | ORPC + TanStack Query | 端到端类型安全 RPC |
| Database | Cloudflare D1/KV | 边缘 Serverless SQLite。 |
| ORM | Drizzle ORM | 轻量级、类型安全的 SQL ORM。 |
| UI | Tailwind V4 + Shadcn | 现代化的原子类与组件库。 |
| Infrastructure | Alchemy | 基于 TS 的基础设施即代码。 |
| Linting | Biome | 极速 Lint 和格式化。 |
starter/
├── apps/
│ ├── server/ # Hono 后端 Worker
│ └── web/ # TanStack Start 前端 Worker(端口 3000)
└── packages/
├── api/ # 共享 ORPC API 定义 & Zod Schemas
├── db/ # Drizzle Schema & Migrations
├── ui/ # 共享 Shadcn UI 组件
└── config/ # 共享 TS 配置
新用户请看完整教程 —— docs/quickstart.md: 从 GitHub「Use this template」到手动部署到自己的 Cloudflare 账号, 再到多环境自动部署(含必填的 auth 环境变量),一步步走完。
- Node.js (v23.6+ — the project runs
.tsfiles directly via Node) - pnpm (
npm i -g pnpm) - Cloudflare 账号
克隆仓库并安装依赖。
git clone https://github.com/saasflare-dev/starter.git
cd starter
pnpm install两个 app 启动时都会传 --env-file .local.env,文件不存在会直接启动失败,所以首次运行前两个都要建。内容可以完全为空 —— alchemy dev --stage local 把 CORS 和客户端 bundle 都写死成 http://localhost:3000 / :4000,其余每一项本地都有可用的默认值。
cp apps/server/.local.env.example apps/server/.local.env
cp apps/web/.local.env.example apps/web/.local.env
pnpm dev
.local.env仅用于本地开发;.dev.env/.prod.env用于 stage 部署(CI 注入)。
登录 Cloudflare 授权部署权限。
pnpm alchemy configure
pnpm alchemy login将所有应用部署到 Cloudflare 全球网络。
# 部署到开发环境
pnpm run deploy:dev
# 部署到生产环境
pnpm run deploy:prod一次部署即可。
alchemy.run.ts通过computeWorkerDevDomain自动解析 URL,NEXT_PUBLIC_SERVER_URL和CORS_ORIGIN不需要手填,deploy:dev/deploy:prod首次运行就能跑通。控制面凭证放在仓库根目录的.alchemy.env;各 app 的部署配置(可选WEB_DOMAIN/SERVER_DOMAIN、auth、R2 keys)放在apps/{server,web}/.{stage}.env。完整流程见 docs/deploy.md。
本项目提供两个 GitHub Actions 工作流:
deploy.yml— push 到dev→ 部署到 开发环境 (starter-web-dev.<account>.workers.dev);push 到main→ 部署到 生产环境 (starter-web-prod.<account>.workers.dev)。preview.yml— 每个针对dev/main的 PR 自动创建独立 stage (pr-<N>),独占 Worker / KV / D1 / R2。bot 会在 PR 评论里贴预览 URL;PR 关闭时自动销毁该 stage。
工作流实际只读取五个 Repository Secrets (Settings -> Secrets and variables -> Actions -> New repository secret)。每个 secret 都是某个本地 env 文件的完整内容,CI 会在部署前把它写回原路径:
| Secret | 本地文件 | 内容 |
|---|---|---|
ENV_ALCHEMY |
.alchemy.env |
控制面凭证(CLOUDFLARE_API_TOKEN、ALCHEMY_STATE_TOKEN)。必需 —— Actions 跑不了交互式的 alchemy login。 |
ENV_SERVER_DEV / ENV_SERVER_PROD |
apps/server/.dev.env / .prod.env |
server Worker 配置 |
ENV_WEB_DEV / ENV_WEB_PROD |
apps/web/.dev.env / .prod.env |
web 部署配置 |
没有独立的 CLOUDFLARE_API_TOKEN / ALCHEMY_STATE_TOKEN repository secret —— 它们随 ENV_ALCHEMY 一起传入。生成方式见 .alchemy.env.example。
或使用辅助脚本(缺失的文件会跳过并给出提示):
pnpm sync:secrets手动等价:
gh secret set ENV_ALCHEMY < .alchemy.env
gh secret set ENV_SERVER_DEV < apps/server/.dev.env
gh secret set ENV_SERVER_PROD < apps/server/.prod.env
gh secret set ENV_WEB_DEV < apps/web/.dev.env
gh secret set ENV_WEB_PROD < apps/web/.prod.envMIT © Saasflare