首页龙虾技能列表 › Vercel to Cloudflare Worker Migration — Vercel工具

Vercel to Cloudflare Worker Migration — Vercel工具

v1.0.0

[AI辅助] Migrate Next.js projects from Vercel to Cloudflare Workers with Supabase/Hyperdrive support. Use when user wants to move a Next.js app off Vercel to reduce c...

0· 480·0 当前·0 累计
by @jiafar·MIT-0
下载技能包
License
MIT-0
最后更新
2026/2/26
安全扫描
VirusTotal
无害
查看报告
OpenClaw
可疑
medium confidence
The skill's purpose and included analysis script match the migration goal, but the runtime instructions reference a missing migration script (scripts/migrate.py) and the SKILL.md gives broad advice that could cause users to run edits that require sensitive DB credentials — the package appears incomplete and therefore potentially unsafe to run as-is.
评估建议
This package mostly looks like a legitimate migration helper, but it's incomplete: SKILL.md tells you to run scripts/migrate.py yet that file is not included. Before running anything, do not fetch or execute external code to compensate for the missing file. Review scripts/analyze_project.py locally (it only reads files and prints a report) and run it in a safe environment (not on production servers or on a repo with unredacted secrets). If you plan to perform the migration: (1) ask the publisher...
详细分析 ▾
用途与能力
Name, description, and the included analysis script (scripts/analyze_project.py) and reference docs consistently target migrating Next.js/Supabase projects from Vercel to Cloudflare Workers with Hyperdrive. The guidance to install @opennextjs/cloudflare and edit next.config/wrangler.toml is appropriate for the stated task.
指令范围
SKILL.md tells the user to run a migration script 'scripts/migrate.py' which is not present in the bundle — this is an incoherence that could lead users to fetch or run unknown external code. The provided analyze_project.py reads the project tree and source files (which is expected) but could expose local secrets if the user runs it in a repo containing credentials; the skill does not explicitly warn about sensitive files. Overall the runtime instructions are specific but incomplete.
安装机制
No install spec is provided (instruction-only plus local helper script). No remote downloads or installers are requested by the package itself, which reduces supply-chain risk. The only external package the instructions ask to install is @opennextjs/cloudflare via npm — expected for this migration.
凭证需求
The skill declares no required environment variables or credentials (consistent with being an instruction-only tool). The migration guidance explains where database connection strings and Hyperdrive bindings belong, but it does not request the skill be given secrets. Users will need to supply DB/Hyperdrive credentials for real migrations — those are appropriately described as local configuration rather than required envs for the skill itself.
持久化与权限
The skill does not request persistent presence (always: false) and has no install actions. It does not modify other skills or global configuration. Autonomous invocation is allowed (platform default) but does not combine with other high-risk indicators here.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/2/20

Initial release: Next.js + Supabase + Hyperdrive migration guide with analysis script

● 无害

安装命令 点击复制

官方npx clawhub@latest install vercel-to-cloudflare
镜像加速npx clawhub@latest install vercel-to-cloudflare --registry https://cn.clawhub-mirror.com

技能文档

Migrate a Next.js + Supabase project from Vercel to Cloudflare Workers with Hyperdrive connection pooling.

Quick 开始

  • Run analysis script 到 scan project:
   python3 scripts/analyze_project.py 
   
  • Review migration 举报
  • Run migration script:
   python3 scripts/migrate.py 
   

Core Migration Steps

1. Install @opennextjs/cloudflare adapter

npm install @opennextjs/cloudflare

Update next.config.js or next.config.ts if needed.

2. Rewrite environment 变量 access

All process.env.XXX for Cloudflare bindings (Hyperdrive, KV, D1, etc.) must use getCloudflareContext():

// BEFORE (Vercel/Node.js)
const url = process.env.DATABASE_URL;

// AFTER (Cloudflare Worker) import { getCloudflareContext } from '@opennextjs/cloudflare';

function getConnectionInfo() { const env = getCloudflareContext().env; const hyperdrive = env.HYPERDRIVE as { connectionString?: string } | undefined; if (hyperdrive?.connectionString) { return { connectionString: hyperdrive.connectionString, source: 'hyperdrive' }; } // Fallback for local dev const local = env.CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE; if (local) { return { connectionString: local, source: 'hyperdrive-local' }; } throw new Error('HYPERDRIVE is not configured'); }

3. Refactor global DB singleton 到 per-请求 pattern

// BEFORE: Global singleton
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
const client = postgres(process.env.DATABASE_URL!);
export const db = drizzle(client);

// AFTER: Per-request with React cache import { cache } from 'react';

export const getDb = cache(() => { const { connectionString, source } = getConnectionInfo(); return createDatabase({ connectionString, enableSSL: source === 'hyperdrive' ? false : 'require', }); });

Then replace all import { db } with import { getDb } and add const db = getDb() at the start of each function.

4. Configure wrangler.toml

name = "my-app"
main = ".open-next/worker.js"
compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]

[[hyperdrive]] binding = "HYPERDRIVE" id = ""

Critical Pitfalls

  • Hyperdrive 必须 connect 到 Supabase Direct 连接 (port 5432), 不 Pooler (port 6543). Hyperdrive 连接 pooler — connecting pooler-到-pooler causes errors.
  • SSL 必须 已禁用 对于 Hyperdrive connections — 工作者 ↔ Hyperdrive internal network. 仅 enable SSL 对于 direct 数据库 connections (local dev, build stage).
  • Cannot initialize DB 在 模块 top levelgetCloudflareContext() 仅 works 期间 请求 handling, 不 在 模块 加载 时间.
  • Supabase Free Tier direct 连接 IPv6 仅 — local dev 可能 失败 如果 network doesn't support IPv6. 使用 Pooler URL (port 6543) 对于 local development.

Detailed References

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务