本文へ移動
cccskills
無料GitHub で公開

cloudflare-workers-frameworks

Framework integration for Cloudflare Workers. Use when building with Hono, Remix, Next.js, Astro, SvelteKit, Qwik, or Nuxt on Workers. Covers routing, SSR, static assets, and edge deployment.

インストール方法を見る

含まれるファイル(15)

  • SKILL.md5.6 KB
  • references/astro.md8.7 KB
  • references/hono.md14.8 KB
  • references/nextjs.md10.2 KB
  • references/nuxt.md9.8 KB
  • references/qwik.md10.3 KB
  • references/remix.md13.3 KB
  • references/sveltekit.md10.4 KB
  • templates/astro-page.astro7.9 KB
  • templates/hono-app.ts7.2 KB
  • templates/nextjs-route.ts10.3 KB
  • templates/nuxt-server.ts14.1 KB
  • templates/qwik-route.tsx12.6 KB
  • templates/remix-loader.tsx10.0 KB
  • templates/sveltekit-route.ts10.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Workers Frameworks Integration

Build full-stack applications on Cloudflare Workers using modern frameworks.

Quick Start: Choose Your Framework

FrameworkBest ForSSRStaticWorkers Native
HonoAPIs, lightweight apps✅✅✅ Native
RemixFull-stack apps✅✅✅ Adapter
Next.jsReact apps✅✅⚠️ OpenNext
AstroContent sites✅✅✅ Adapter
SvelteKitSvelte apps✅✅✅ Adapter
QwikResumable apps✅✅✅ Adapter
NuxtVue apps✅✅✅ Nitro

Framework Decision Tree

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

Top 10 Framework Errors

ErrorFrameworkCauseSolution
No matching export "default"AllWrong export formatUse export default app not module.exports
Worker exceeded CPU limitNext.jsHeavy SSRUse ISR, reduce bundle size
Cannot read properties of undefined (reading 'env')RemixMissing contextPass context to loader/action
globalThis is not definedAllNode.js globalsUse nodejs_compat flag
Dynamic require not supportedAllCJS in ESMConvert to ESM imports
Response body is lockedAllBody already readClone response before reading
Bindings not availableAllMissing wrangler configAdd bindings to wrangler.jsonc
404 on static assetsAllWrong assets configConfigure assets in wrangler.jsonc
Hydration mismatchReact/VueServer/client differEnsure consistent rendering
Maximum call stack exceededAllCircular importsRefactor module structure

Hono Quick Start (Recommended)

// 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" }
  ]
}

Static Assets Configuration

// 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;

When to Load References

Load the specific framework reference when user:

ReferenceLoad When
references/hono.mdBuilding APIs, microservices, or lightweight apps
references/remix.mdFull-stack React with loaders/actions
references/nextjs.mdNext.js App Router on Workers via OpenNext
references/astro.mdContent sites, blogs, docs, marketing pages
references/sveltekit.mdSvelte applications on Workers
references/qwik.mdResumable apps, instant loading
references/nuxt.mdVue 3 applications with Nitro

Common Patterns Across Frameworks

Environment Bindings Access

// 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

Error Handling Pattern

// 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
  );
});

Performance Tips

  1. Bundle Size: Keep under 1MB compressed
  2. Cold Starts: Minimize top-level code
  3. Streaming: Use streaming SSR when available
  4. Caching: Leverage Cache API and CDN
  5. Code Splitting: Dynamic imports for routes

See Also

  • workers-performance - Optimization techniques
  • workers-runtime-apis - Workers APIs reference
  • cloudflare-worker-base - Basic Workers setup

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

100+ animated React components (Aceternity UI) for Next.js with Tailwind. Use for hero sections, parallax, 3D effects, or encountering animation, shadcn CLI integration errors.

日本語の概要は準備中です。原文の説明を表示しています。

secondsky/claude-skills2272026年9月28日 更新

Secure API authentication with JWT, OAuth 2.0, API keys. Use for authentication systems, third-party integrations, service-to-service communication, or encountering token management, security headers, auth flow errors.

日本語の概要は準備中です。原文の説明を表示しています。

secondsky/claude-skills2272026年9月28日 更新

Creates comprehensive API changelogs documenting breaking changes, deprecations, and migration strategies for API consumers. Use when managing API versions, communicating breaking changes, or creating upgrade guides.

日本語の概要は準備中です。原文の説明を表示しています。

secondsky/claude-skills2272026年9月28日 更新

Verifies API contracts between services using consumer-driven contracts, schema validation, and tools like Pact. Use when testing microservices communication, preventing breaking changes, or validating OpenAPI specifications.

日本語の概要は準備中です。原文の説明を表示しています。

secondsky/claude-skills2272026年9月28日 更新

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

日本語の概要は準備中です。原文の説明を表示しています。

secondsky/claude-skills2272026年9月28日 更新

Implements standardized API error responses with proper status codes, logging, and user-friendly messages. Use when building production APIs, implementing error recovery patterns, or integrating error monitoring services.

日本語の概要は準備中です。原文の説明を表示しています。

secondsky/claude-skills2272026年9月28日 更新

secondsky のスキルをすべて見る

このスキルの問題を報告する