> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trytrellis.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Cloudflare Workers + Hono + Turso

> Cloudflare Workers 全栈应用 + Hono 框架 + Turso 数据库的编码规范模板

适用于生产级 Cloudflare Workers 应用的完整编码规范模板，包含 Hono 框架、Drizzle ORM 和 Turso 边缘数据库。

<Card title="下载模板" icon="download" href="https://download-directory.github.io/?url=https://github.com/mindfold-ai/Trellis/tree/main/marketplace/specs/cf-workers-fullstack">
  下载 ZIP 并解压到 `.trellis/spec/`
</Card>

## 包含内容

| 分类 | 文件数      | 覆盖范围                            |
| -- | -------- | ------------------------------- |
| 后端 | 11 个     | Hono、Drizzle/Turso、API 模式、安全、存储 |
| 前端 | 7 个 + 示例 | 组件、Hooks、认证、设计模板                |
| 共享 | 5 个      | TypeScript、代码质量、依赖管理、时间戳        |
| 指南 | 3 个      | OAuth 授权流程、Serverless 连接调试      |
| 坑点 | 6 个      | Workers 兼容性、跨层契约、环境配置、CSS       |

## 模板结构

```
spec/
├── backend/
│   ├── index.md
│   ├── hono-framework.md
│   ├── database.md
│   ├── api-module.md
│   ├── api-patterns.md
│   ├── security.md
│   ├── storage.md
│   └── ...
│
├── frontend/
│   ├── index.md
│   ├── authentication.md
│   ├── components.md
│   ├── hooks.md
│   ├── directory-structure.md
│   ├── examples/frontend-design/
│   └── ...
│
├── guides/
│   ├── oauth-consent-flow.md
│   ├── serverless-connection-guide.md
│   └── ...
│
├── shared/
│   ├── typescript.md
│   ├── code-quality.md
│   ├── dependency-versions.md
│   └── ...
│
├── big-question/
│   ├── workers-nodejs-compat.md
│   ├── cross-layer-contract.md
│   ├── env-configuration.md
│   └── ...
│
└── README.md
```

## 主要内容

### 后端

* Hono 框架模式（类型安全 Bindings、中间件、WebSocket）
* Drizzle ORM + Turso/libSQL（批量操作、N+1 防护、Workers 限制）
* Cloudflare 存储（R2、KV、Cache API 会话缓存）
* 安全（Token 生成、时序安全比较、OAuth 重定向验证）
* 请求上下文结构化 JSON 日志

### 前端

* React 19 + React Router v7 + Vite
* Better Auth UI v3.x 集成（SSR 安全、Cloudflare Workers 适配）
* shadcn/ui 组件 + Tailwind CSS v4
* 设计示例模板（极简 Hero、极繁仪表盘、动画库）

### 指南

* OAuth 2.1 授权流程与资源选择
* Serverless 连接调试（过期连接、子请求限制）

### 常见坑点

* Workers Node.js 兼容性（`nodejs_compat` 标志）
* 跨层契约违反（数据流通但客户端收不到）
* 构建时 vs 运行时环境变量
* Tailwind v4 CSS 调试

## 使用方法

1. 下载 ZIP 文件
2. 解压到项目的 `.trellis/spec/` 目录
3. 将通用环境变量名替换为你的实际 Bindings
4. 按你项目的具体规范修改
5. 删掉不适用的部分

<Card title="在 GitHub 上查看" icon="github" href="https://github.com/mindfold-ai/Trellis/tree/main/marketplace/specs/cf-workers-fullstack">
  浏览模板源码
</Card>
