Token导航 LogoToken导航

Agent Skill · 前端设计

cloudflare-opennext(Cloudflare opennext 命令行)

cloudflare-opennext 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

cloudflare-opennext 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 1,659。

总安装 4,422周安装 188GitHub Stars 公开资料未说明下载 1,549核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:cloudflare-opennext(Cloudflare opennext 命令行)
来源仓库:https://github.com/null-shot/cloudflare-skills
仓库路径:skills/cloudflare-opennext
安装命令:
npx skills add https://github.com/null-shot/cloudflare-skills --skill cloudflare-opennext
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/null-shot/cloudflare-skills --skill cloudflare-opennext

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

使用 @opennextjs/cloudflare 适配器部署 Next.js 到 Workers,兼容 App/Pages Router。支持 ISR、SSG、Cloudflare 绑定(KV、R2、D1、AI)及 ORM 集成。适用于新建或迁移 Next.js 项目,解决 bundle 体积与部署兼容性问题。

初始化命令包含框架选择与模板,后续通过 npm run dev/build 本地调试。需注意 Node.js 兼容标志与边缘运行时 API 差异处理。

来源仓库内路径:skills/cloudflare-opennext

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/null-shot/cloudflare-skills --skill cloudflare…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

cloudflare-opennext 怎么安装?

在终端执行 npx skills add https://github.com/null-shot/cloudflare-skills --skill cloudflare-opennext。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

cloudflare-opennext 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

cloudflare-opennext 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

cloudflare-opennext 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

cloudflare-opennext 用的人多吗?

公开数据是累计安装 4,422 次,近一周安装 188 次,下载 1,549 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

cloudflare-opennext 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
cloudflare-opennext

Cloudflare opennext 命令行 · 本页

4,422—接触敏感数据未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Cloudflare OpenNext

Deploy Next.js applications to Cloudflare Workers using the @opennextjs/cloudflare adapter with full support for App Router, Pages Router, ISR, SSG, and Cloudflare bindings.

When to Use

  • Creating new Next.js apps for Cloudflare Workers
  • Migrating existing Next.js apps to Cloudflare
  • Configuring ISR/SSG caching with R2, KV, or D1
  • Accessing Cloudflare bindings (KV, R2, D1, Durable Objects, AI)
  • Using databases and ORMs (Drizzle, Prisma) in Next.js
  • Troubleshooting deployment issues or bundle size problems

Getting Started

New App

npm create cloudflare@latest -- my-next-app --framework=next --platform=workers
cd my-next-app
npm run dev      # Local development with Next.js
npm run preview  # Preview in Workers runtime
npm run deploy   # Deploy to Cloudflare

Existing App Migration

# 1. Install dependencies
npm install @opennextjs/cloudflare@latest
npm install --save-dev wrangler@latest

# 2. Create wrangler.jsonc (see Configuration section)
# 3. Create open-next.config.ts
# 4. Update next.config.ts
# 5. Add scripts to package.json
# 6. Deploy
npm run deploy

Core Concepts

How OpenNext Works

The @opennextjs/cloudflare adapter:

  1. Runs next build to generate the Next.js build output
  2. Transforms the build output to work in Cloudflare Workers runtime
  3. Outputs to .open-next/ directory with worker.js entry point
  4. Uses Workers Static Assets for static files (_next/static, public)

Node.js Runtime (Not Edge)

Critical: OpenNext uses Next.js Node.js runtime, NOT the Edge runtime:

// ❌ Remove this - Edge runtime not supported
export const runtime = "edge";

// ✅ Default Node.js runtime - fully supported
// No export needed, this is the default

The Node.js runtime provides:

  • Full Node.js API compatibility via nodejs_compat flag
  • More Next.js features than Edge runtime
  • Access to all Cloudflare bindings

Configuration Files

wrangler.jsonc

Minimal configuration for OpenNext:

{
  "$schema": "node_modules/wrangler/config-schema.json",
  "name": "my-nextjs-app",
  "main": ".open-next/worker.js",
  "compatibility_date": "2024-12-30",
  "compatibility_flags": [
    "nodejs_compat",                    // Required for Node.js APIs
    "global_fetch_strictly_public"      // Security: prevent local IP fetches
  ],
  "assets": {
    "directory": ".open-next/assets",   // Static files
    "binding": "ASSETS"
  },
  "services": [
    {
      "binding": "WORKER_SELF_REFERENCE",
      "service": "my-nextjs-app"        // Must match "name" above
    }
  ],
  "images": {
    "binding": "IMAGES"                 // Optional: Enable image optimization
  }
}

Required settings:

  • nodejs_compat compatibility flag
  • compatibility_date >= 2024-09-23
  • WORKER_SELF_REFERENCE service binding (must match worker name)
  • main and assets paths should not be changed

See references/configuration.md for complete configuration with R2, KV, D1 bindings.

open-next.config.ts

Configure caching and OpenNext behavior:

import { defineCloudflareConfig } from "@opennextjs/cloudflare";
import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache";

export default defineCloudflareConfig({
  incrementalCache: r2IncrementalCache,
});

This file is auto-generated if not present. See references/caching.md for cache options.

next.config.ts

Initialize OpenNext for local development:

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  // Your Next.js configuration
};

export default nextConfig;

// Enable bindings access during `next dev`
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
initOpenNextCloudflareForDev();

.dev.vars

Environment variables for local development:

# .dev.vars
NEXTJS_ENV=development

The NEXTJS_ENV variable selects which Next.js .env file to load:

  • development → .env.development
  • production → .env.production (default)

Accessing Cloudflare Bindings

Use getCloudflareContext() to access bindings in any route:

import { getCloudflareContext } from "@opennextjs/cloudflare";

// Route Handler (App Router)
export async function GET(request: Request) {
  const { env, cf, ctx } = getCloudflareContext();

  // Access KV
  const value = await env.MY_KV.get("key");

  // Access R2
  const object = await env.MY_BUCKET.get("file.txt");

  // Access D1
  const result = await env.DB.prepare("SELECT * FROM users").all();

  // Access Durable Objects
  const stub = env.MY_DO.idFromName("instance-1");
  const doResponse = await stub.fetch(request);

  // Access request info
  const country = cf?.country;

  // Background tasks
  ctx.waitUntil(logAnalytics());

  return Response.json({ value });
}

// API Route (Pages Router)
export default async function handler(req, res) {
  const { env } = getCloudflareContext();
  const data = await env.MY_KV.get("key");
  res.json({ data });
}

// Server Component
export default async function Page() {
  const { env } = getCloudflareContext();
  const data = await env.MY_KV.get("key");
  return <div>{data}</div>;
}

SSG Routes with Async Context

For Static Site Generation routes, use async mode:

// In SSG route (generateStaticParams, etc.)
const { env } = await getCloudflareContext({ async: true });
const products = await env.DB.prepare("SELECT * FROM products").all();

Warning: During SSG, secrets from .dev.vars and local binding values are included in the static build. Be careful with sensitive data.

TypeScript Types

Generate types for your bindings:

npx wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts

Add to package.json:

{
  "scripts": {
    "cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts"
  }
}

Run after any binding changes in wrangler.jsonc.

CLI Commands

The opennextjs-cloudflare CLI wraps Wrangler with OpenNext-specific behavior:

# Build the Next.js app and transform for Workers
npx opennextjs-cloudflare build

# Build and preview locally with Wrangler
npm run preview
# or
npx opennextjs-cloudflare preview

# Build and deploy to Cloudflare
npm run deploy
# or
npx opennextjs-cloudflare deploy

# Build and upload as a version (doesn't deploy)
npm run upload
# or
npx opennextjs-cloudflare upload

# Populate cache (called automatically by preview/deploy/upload)
npx opennextjs-cloudflare populateCache local   # Local bindings
npx opennextjs-cloudflare populateCache remote  # Remote bindings

Recommended package.json scripts:

{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview",
    "deploy": "opennextjs-cloudflare build && opennextjs-cloudflare deploy",
    "upload": "opennextjs-cloudflare build && opennextjs-cloudflare upload",
    "cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts"
  }
}

Caching Strategies

OpenNext supports Next.js caching with Cloudflare storage:

Cache TypeUse CaseStorage Options
Incremental CacheISR/SSG page dataR2, KV, Static Assets
QueueTime-based revalidationDurable Objects, Memory
Tag CacheOn-demand revalidationD1, Durable Objects

Quick setup examples:

// Static Site (SSG only)
import staticAssetsCache from "@opennextjs/cloudflare/overrides/incremental-cache/static-assets-incremental-cache";
export default defineCloudflareConfig({
  incrementalCache: staticAssetsCache,
  enableCacheInterception: true,
});

// Small Site with ISR
import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache";
export default defineCloudflareConfig({
  incrementalCache: r2IncrementalCache,
  queue: doQueue,
  tagCache: d1NextTagCache,
});

See references/caching.md for complete caching patterns including regional cache and sharded tag cache

Image Optimization

Enable Cloudflare Images for automatic image optimization:

// wrangler.jsonc
{
  "images": {
    "binding": "IMAGES"
  }
}

Next.js <Image> components will automatically use Cloudflare Images. Additional costs apply.

Compatibility notes:

  • Supports: PNG, JPEG, WEBP, AVIF, GIF, SVG
  • minimumCacheTTL not supported
  • dangerouslyAllowLocalIP not supported

Database and ORM Patterns

Critical Rule: Never create global database clients in Workers. Create per-request:

// ❌ WRONG - Global client causes I/O errors
import { Pool } from "pg";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });

// ✅ CORRECT - Per-request client
import { cache } from "react";
import { Pool } from "pg";

export const getDb = cache(() => {
  const pool = new Pool({
    connectionString: process.env.DATABASE_URL,
    maxUses: 1,  // Don't reuse connections across requests
  });
  return drizzle({ client: pool, schema });
});

// Usage in route
export async function GET() {
  const db = getDb();
  const users = await db.select().from(usersTable);
  return Response.json(users);
}

See references/database-orm.md for Drizzle and Prisma patterns.

Critical Rules

✅ DO

  1. Use Node.js runtime - Default runtime, remove any export const runtime = "edge"
  2. Create DB clients per-request - Use React's cache() for request-scoped instances
  3. Enable nodejs_compat - Required compatibility flag with date >= 2024-09-23
  4. Use getCloudflareContext() - Access bindings, not getRequestContext from next-on-pages
  5. Add.open-next to.gitignore - Build output should not be committed
  6. Use wrangler.jsonc - Not wrangler.toml (JSONC supports comments and validation)
  7. Set WORKER_SELF_REFERENCE - Service binding must match worker name
  8. Add public/_headers - Configure static asset caching headers

❌ DON'T

  1. Don't use Edge runtime - Remove export const runtime = "edge" from all routes
  2. Don't use Turbopack - Use next build, not next build --turbo
  3. Don't create global DB clients - Causes "Cannot perform I/O" errors
  4. Don't exceed 10 MiB - Worker size limit (3 MiB on free plan)
  5. Don't use next-on-pages - Different adapter, use @opennextjs/cloudflare instead
  6. Don't commit.open-next/ - Build output directory
  7. Don't use Node Middleware - Not supported (Next.js 15.2+ feature)

Supported Features

FeatureSupportNotes
App Router✅ FullAll features supported
Pages Router✅ FullIncluding API routes
Route Handlers✅ FullGET, POST, etc.
Dynamic Routes✅ Full[slug], [...slug]
SSG✅ FullStatic Site Generation
SSR✅ FullServer-Side Rendering
ISR✅ FullIncremental Static Regeneration
PPR✅ FullPartial Prerendering
Middleware✅ PartialStandard middleware works, Node Middleware (15.2+) not supported
Image Optimization✅ FullVia Cloudflare Images binding
Composable Caching✅ Full'use cache' directive
next/font✅ FullFont optimization
after()✅ FullBackground tasks
Turbopack❌ NoUse standard build

Supported Next.js versions:

  • Next.js 15: All minor and patch versions
  • Next.js 14: Latest minor version only

Development Workflow

# Local development with Next.js dev server
npm run dev

# Preview in Workers runtime (faster than deploy)
npm run preview

# Deploy to production
npm run deploy

# Update TypeScript types after binding changes
npm run cf-typegen

Local Development Notes:

  • next dev - Uses Node.js runtime, bindings available via initOpenNextCloudflareForDev()
  • npm run preview - Uses Workers runtime with Wrangler, closer to production
  • Both support hot reloading

Detailed References

Migration from @cloudflare/next-on-pages

If migrating from @cloudflare/next-on-pages:

  1. Uninstall @cloudflare/next-on-pages and eslint-plugin-next-on-pages
  2. Install @opennextjs/cloudflare
  3. Update next.config.ts:

- Remove setupDevPlatform() calls - Replace with initOpenNextCloudflareForDev()

  1. Update imports:

- Replace getRequestContext from @cloudflare/next-on-pages - Use getCloudflareContext from @opennextjs/cloudflare

  1. Remove Edge runtime exports (export const runtime = "edge")
  2. Update wrangler.jsonc with required OpenNext settings
  3. Remove next-on-pages eslint rules

Examples

Official examples in the @opennextjs/cloudflare repository:

  • create-next-app - Basic Next.js starter
  • middleware - Middleware usage
  • vercel-blog-starter - SSG blog example

Best Practices

  1. Start simple - Use Static Assets cache for SSG-only sites
  2. Add caching gradually - Enable R2 cache when you need ISR
  3. Monitor bundle size - Stay under 10 MiB compressed (use ESBuild Bundle Analyzer)
  4. Use TypeScript - Run cf-typegen to get binding types
  5. Test with preview - Use npm run preview before deploying
  6. Cache database clients - Use React's cache() for per-request instances
  7. Enable observability - Add observability to wrangler.jsonc for logging
  8. Use remote bindings for build - Enable for ISR with real data

Common Patterns

See references/configuration.md for complete examples including:

  • Custom Worker with multiple handlers (fetch, scheduled, queue)
  • Environment-specific configuration (staging, production)
  • Remote bindings for build-time data access

Resources

平台分布

Codex

35.85%
按下载量换算555

Claude

29.22%
按下载量换算453

Cursor

19.49%
按下载量换算302

Gemini CLI

10.56%
按下载量换算164

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills