重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
workers-frameworks by secondsky/claude-skills
npx skills add https://github.com/secondsky/claude-skills --skill workers-frameworks使用现代框架在 Cloudflare Workers 上构建全栈应用程序。
| 框架 | 最适合 | SSR | 静态 | Workers 原生 |
|---|---|---|---|---|
| Hono | API、轻量级应用 | ✅ | ✅ | ✅ 原生 |
| Remix | 全栈应用 | ✅ | ✅ | ✅ 适配器 |
| Next.js | React 应用 | ✅ | ✅ | ⚠️ OpenNext |
| Astro | 内容网站 | ✅ | ✅ | ✅ 适配器 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| SvelteKit |
| Svelte 应用 |
| ✅ |
| ✅ |
| ✅ 适配器 |
| Qwik | 可恢复应用 | ✅ | ✅ | ✅ 适配器 |
| Nuxt | Vue 应用 | ✅ | ✅ | ✅ Nitro |
Need an API only?
└─ Yes → Hono (fastest, smallest)
└─ No → Building a full app?
└─ React → Next.js (OpenNext) or Remix
└─ Vue → Nuxt
└─ Svelte → SvelteKit
└─ Content-heavy → Astro
└─ Max performance → Qwik
| 错误 | 框架 | 原因 | 解决方案 |
|---|---|---|---|
No matching export "default" | 所有 | 错误的导出格式 | 使用 export default app 而非 module.exports |
Worker exceeded CPU limit | Next.js | 繁重的 SSR | 使用 ISR,减少包大小 |
Cannot read properties of undefined (reading 'env') | Remix | 缺少上下文 | 将 context 传递给 loader/action |
globalThis is not defined | 所有 | Node.js 全局对象 | 使用 nodejs_compat 标志 |
Dynamic require not supported | 所有 | ESM 中的 CJS | 转换为 ESM 导入 |
Response body is locked | 所有 | 响应体已被读取 | 在读取前克隆响应 |
Bindings not available | 所有 | 缺少 wrangler 配置 | 在 wrangler.jsonc 中添加绑定 |
404 on static assets | 所有 | 错误的静态资源配置 | 在 wrangler.jsonc 中配置 assets |
Hydration mismatch | React/Vue | 服务端/客户端不一致 | 确保渲染一致性 |
Maximum call stack exceeded | 所有 | 循环导入 | 重构模块结构 |
// src/index.ts
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { logger } from 'hono/logger';
interface Env {
DB: D1Database;
KV: KVNamespace;
}
const app = new Hono<{ Bindings: Env }>();
// Middleware
app.use('*', logger());
app.use('/api/*', cors());
// Routes
app.get('/', (c) => c.text('Hello Workers!'));
app.get('/api/users', async (c) => {
const { results } = await c.env.DB.prepare('SELECT * FROM users').all();
return c.json(results);
});
app.post('/api/users', async (c) => {
const { name, email } = await c.req.json();
await c.env.DB.prepare('INSERT INTO users (name, email) VALUES (?, ?)')
.bind(name, email)
.run();
return c.json({ success: true }, 201);
});
export default app;
// wrangler.jsonc
{
"name": "my-app",
"main": "src/index.ts",
"compatibility_date": "2024-12-01",
"compatibility_flags": ["nodejs_compat"],
"d1_databases": [
{ "binding": "DB", "database_name": "my-db", "database_id": "xxx" }
]
}
// wrangler.jsonc - Serving static files
{
"name": "my-app",
"main": "src/index.ts",
"assets": {
"directory": "./public",
"binding": "ASSETS"
}
}
// Serve static with fallback to app
import { Hono } from 'hono';
const app = new Hono<{ Bindings: { ASSETS: Fetcher } }>();
// API routes
app.get('/api/*', apiHandler);
// Static assets fallback
app.get('*', async (c) => {
return c.env.ASSETS.fetch(c.req.raw);
});
export default app;
当用户进行以下操作时,加载特定的框架参考文档:
| 参考文档 | 加载时机 |
|---|---|
references/hono.md | 构建 API、微服务或轻量级应用时 |
references/remix.md | 使用 loaders/actions 的全栈 React 应用时 |
references/nextjs.md | 通过 OpenNext 在 Workers 上使用 Next.js App Router 时 |
references/astro.md | 构建内容网站、博客、文档、营销页面时 |
references/sveltekit.md | 在 Workers 上构建 Svelte 应用时 |
references/qwik.md | 构建可恢复应用、需要即时加载时 |
references/nuxt.md | 使用 Nitro 构建 Vue 3 应用时 |
// Hono
app.get('/', (c) => c.env.DB.prepare('...'));
// Remix
export async function loader({ context }) {
return context.cloudflare.env.DB.prepare('...');
}
// Astro
const db = Astro.locals.runtime.env.DB;
// SvelteKit
export async function load({ platform }) {
return platform.env.DB.prepare('...');
}
// Nuxt
const { cloudflare } = useRuntimeConfig();
// Or via nitro: event.context.cloudflare.env.DB
// Universal error boundary pattern
app.onError((err, c) => {
console.error(`[${c.req.path}] ${err.message}`);
if (err instanceof HTTPException) {
return err.getResponse();
}
return c.json(
{ error: 'Internal Server Error' },
500
);
});
workers-performance - 优化技术workers-runtime-apis - Workers API 参考cloudflare-worker-base - 基础 Workers 设置每周安装量
66
代码仓库
GitHub 星标数
90
首次出现
2026年1月25日
安全审计
安装于
claude-code58
gemini-cli50
codex50
cursor50
opencode49
github-copilot46
Build full-stack applications on Cloudflare Workers using modern frameworks.
| Framework | Best For | SSR | Static | Workers Native |
|---|---|---|---|---|
| Hono | APIs, lightweight apps | ✅ | ✅ | ✅ Native |
| Remix | Full-stack apps | ✅ | ✅ | ✅ Adapter |
| Next.js | React apps | ✅ | ✅ | ⚠️ OpenNext |
| Astro | Content sites | ✅ | ✅ | ✅ Adapter |
| SvelteKit | Svelte apps | ✅ | ✅ | ✅ Adapter |
| Qwik | Resumable apps | ✅ | ✅ | ✅ Adapter |
| Nuxt | Vue apps | ✅ | ✅ | ✅ Nitro |
Need an API only?
└─ Yes → Hono (fastest, smallest)
└─ No → Building a full app?
└─ React → Next.js (OpenNext) or Remix
└─ Vue → Nuxt
└─ Svelte → SvelteKit
└─ Content-heavy → Astro
└─ Max performance → Qwik
| Error | Framework | Cause | Solution |
|---|---|---|---|
No matching export "default" | All | Wrong export format | Use export default app not module.exports |
Worker exceeded CPU limit | Next.js | Heavy SSR | Use ISR, reduce bundle size |
Cannot read properties of undefined (reading 'env') | Remix | Missing context | Pass to loader/action |
// src/index.ts
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import { logger } from 'hono/logger';
interface Env {
DB: D1Database;
KV: KVNamespace;
}
const app = new Hono<{ Bindings: Env }>();
// Middleware
app.use('*', logger());
app.use('/api/*', cors());
// Routes
app.get('/', (c) => c.text('Hello Workers!'));
app.get('/api/users', async (c) => {
const { results } = await c.env.DB.prepare('SELECT * FROM users').all();
return c.json(results);
});
app.post('/api/users', async (c) => {
const { name, email } = await c.req.json();
await c.env.DB.prepare('INSERT INTO users (name, email) VALUES (?, ?)')
.bind(name, email)
.run();
return c.json({ success: true }, 201);
});
export default app;
// wrangler.jsonc
{
"name": "my-app",
"main": "src/index.ts",
"compatibility_date": "2024-12-01",
"compatibility_flags": ["nodejs_compat"],
"d1_databases": [
{ "binding": "DB", "database_name": "my-db", "database_id": "xxx" }
]
}
// wrangler.jsonc - Serving static files
{
"name": "my-app",
"main": "src/index.ts",
"assets": {
"directory": "./public",
"binding": "ASSETS"
}
}
// Serve static with fallback to app
import { Hono } from 'hono';
const app = new Hono<{ Bindings: { ASSETS: Fetcher } }>();
// API routes
app.get('/api/*', apiHandler);
// Static assets fallback
app.get('*', async (c) => {
return c.env.ASSETS.fetch(c.req.raw);
});
export default app;
Load the specific framework reference when user:
| Reference | Load When |
|---|---|
references/hono.md | Building APIs, microservices, or lightweight apps |
references/remix.md | Full-stack React with loaders/actions |
references/nextjs.md | Next.js App Router on Workers via OpenNext |
references/astro.md | Content sites, blogs, docs, marketing pages |
references/sveltekit.md | Svelte applications on Workers |
references/qwik.md |
// Hono
app.get('/', (c) => c.env.DB.prepare('...'));
// Remix
export async function loader({ context }) {
return context.cloudflare.env.DB.prepare('...');
}
// Astro
const db = Astro.locals.runtime.env.DB;
// SvelteKit
export async function load({ platform }) {
return platform.env.DB.prepare('...');
}
// Nuxt
const { cloudflare } = useRuntimeConfig();
// Or via nitro: event.context.cloudflare.env.DB
// Universal error boundary pattern
app.onError((err, c) => {
console.error(`[${c.req.path}] ${err.message}`);
if (err instanceof HTTPException) {
return err.getResponse();
}
return c.json(
{ error: 'Internal Server Error' },
500
);
});
workers-performance - Optimization techniquesworkers-runtime-apis - Workers APIs referencecloudflare-worker-base - Basic Workers setupWeekly Installs
66
Repository
GitHub Stars
90
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code58
gemini-cli50
codex50
cursor50
opencode49
github-copilot46
Bankr杠杆交易插件:通过自然语言指令进行加密货币永续合约交易
Bankr Agent API 核心要点:异步任务模式、加密货币交易与市场分析接口指南
Bankr代币部署工具:一键创建管理ERC20代币,支持Base和Unichain区块链
Salesforce Pardot 营销自动化集成指南:潜在客户管理与API操作
52 周安装
Bankr Polymarket 插件:在 Claude 中直接交易 Polymarket 预测市场,支持自动跨链桥接
Bankr NFT操作插件 - 跨链浏览购买管理NFT,支持OpenSea、Base、Ethereum、Polygon
contextglobalThis is not defined | All | Node.js globals | Use nodejs_compat flag |
Dynamic require not supported | All | CJS in ESM | Convert to ESM imports |
Response body is locked | All | Body already read | Clone response before reading |
Bindings not available | All | Missing wrangler config | Add bindings to wrangler.jsonc |
404 on static assets | All | Wrong assets config | Configure assets in wrangler.jsonc |
Hydration mismatch | React/Vue | Server/client differ | Ensure consistent rendering |
Maximum call stack exceeded | All | Circular imports | Refactor module structure |
| Resumable apps, instant loading |
references/nuxt.md | Vue 3 applications with Nitro |