Skip to main content
skill CX Codex

cloudflare-workers-frameworks — Claude Code skill for Workers

Tells your agent how to run Hono, Remix, Next.js, Astro, SvelteKit, Qwik or Nuxt on Cloudflare Workers, and walks through the usual build errors.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add secondsky/claude-skills --skill cloudflare-workers-frameworks -a claude-code
Open on GitHub

What cloudflare-workers-frameworks does

The skill kicks in when you build on Cloudflare Workers and want guidance for a specific framework. It opens with a comparison table: Hono for APIs and small apps, Remix for full-stack React, Next.js through OpenNext, Astro for content sites, plus SvelteKit, Qwik and Nuxt via Nitro. A decision tree follows — API only means Hono, Vue means Nuxt, React means Next.js or Remix.

Then come ten common errors with cause and fix. No matching export "default" from using module.exports instead of export default app, Worker exceeded CPU limit on heavy Next.js SSR, globalThis is not defined without the nodejs_compat flag, Bindings not available when wrangler.jsonc is missing entries. There is a working Hono example with D1 and KV, a wrangler.jsonc config for static files through assets, and binding-access patterns for Remix, Astro, SvelteKit and Nuxt.

The skill points to separate files — references/hono.md, references/remix.md, references/nextjs.md, references/astro.md, references/sveltekit.md, references/qwik.md, references/nuxt.md — and the agent loads the one matching your task. Worth knowing: Next.js is the only framework in the table marked as needing an adapter, OpenNext. If your Next.js project does not use OpenNext, the deployment advice will not match your setup.

What it helps with

  • pick a framework for a Cloudflare Workers project
  • stand up a Hono API backed by D1 and KV
  • debug Worker exceeded CPU limit during SSR
  • serve static files through assets in wrangler.jsonc
  • read environment bindings in Remix, Astro or SvelteKit

Example prompts for the agent

  • Help me pick a framework for a new Cloudflare Workers project — API only.
  • Scaffold a Hono app with a D1 database and show the wrangler.jsonc config.
  • I keep getting globalThis is not defined on Workers. What should I change?

How to install cloudflare-workers-frameworks

1Skills CLI (Vercel)

npx skills add secondsky/claude-skills --skill cloudflare-workers-frameworks -a claude-code

2Manually: put the files in place

~/.claude/skills/cloudflare-workers-frameworks/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cloudflare-workers-frameworks/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cloudflare-workers-frameworks

How do I install cloudflare-workers-frameworks in Claude?

Run npx skills add secondsky/claude-skills --skill cloudflare-workers-frameworks -a claude-code. The skill file then lands at ~/.claude/skills/cloudflare-workers-frameworks/SKILL.md.

What does cloudflare-workers-frameworks do?

It guides your agent through building Cloudflare Workers apps with Hono, Remix, Next.js, Astro, SvelteKit, Qwik or Nuxt. It covers routing, SSR, static assets and edge deployment, plus the errors that show up along the way.

Which frameworks does the skill cover?

Hono, Remix, Next.js, Astro, SvelteKit, Qwik and Nuxt. Next.js is routed through OpenNext; the rest use adapters or run natively.

Source text

SKILL.md · MIT
---
name: cloudflare-workers-frameworks
description: 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.
metadata:
  version: "1.0.0"
license: MIT
---

# Workers Frameworks Integration

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

## Quick Start: Choose Your Framework

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

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

| 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 `context` to loader/action |
| `globalThis 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 |

## Hono Quick Start (Recommended)

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

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

```jsonc
// wrangler.jsonc - Serving static files
{
  "name": "my-app",
  "main": "src/index.ts",
  "assets": {
    "directory": "./public",
    "binding": "ASSETS"
  }
}
```

```typescript
// 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:

| 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` | Resumable apps, instant loading |
| `references/nuxt.md` | Vue 3 applications with Nitro |

## Common Patterns Across Frameworks

### Environment Bindings Access

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

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

© secondsky · MIT · secondsky/claude-skills

Similar skills

All skills for Cloud: AWS, Azure, GCP →

From the same set94

maz-ui This skill teaches your agent Maz-UI v4: 50+ components, composables and directives for Vue 3 and Nuxt 3. Handy when you build forms, dialogs or data tables. CX Codex +1 369installs woocommerce-dev-cycle A skill that walks you through the WooCommerce dev cycle: run tests, fix code style, sort out linting errors. CX Codex +1 361installs woocommerce-copy-guidelines A skill that sets the rules for user-facing text in WooCommerce: button labels, field names, messages and docs. Useful when more than one person writes the storefront strings. CX Codex +1 363installs cloudflare-workers-testing A skill for writing Cloudflare Workers tests with Vitest and real D1, KV, R2 and Durable Objects bindings. Useful when tests break on mocks or can't see the environment. CX Codex +1 325installs nuxt-seo A skill covering the eight Nuxt SEO v5 modules: robots.txt, sitemaps, OG images, Schema.org and meta tags. Useful when a Nuxt app needs SEO wired up. CX Codex +1 324installs cloudflare-workers-performance A Claude skill for Cloudflare Workers performance: CPU, memory, caching, bundle size. Useful when a worker is slow or hitting limits. CX Codex +1 315installs cloudflare-workers-runtime-apis A skill covering the Cloudflare Workers runtime APIs: Fetch, Streams, Crypto, Cache, WebSockets and text encoding. Handy when a worker trips over requests, streams or cache. CX Codex +1 311installs cloudflare-workers-observability A skill for Cloudflare Workers observability: structured logging, Analytics Engine, Tail Workers, metrics and alerting. Useful when a worker fails in production and you can't see why. CX Codex +1 302installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor