{
  "schemaVersion": "1.0",
  "item": {
    "slug": "vercel-to-cloudflare",
    "name": "Vercel to Cloudflare Worker Migration",
    "source": "tencent",
    "type": "skill",
    "category": "效率提升",
    "sourceUrl": "https://clawhub.ai/jiafar/vercel-to-cloudflare",
    "canonicalUrl": "https://clawhub.ai/jiafar/vercel-to-cloudflare",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/vercel-to-cloudflare",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=vercel-to-cloudflare",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "references/env-patterns.md",
      "references/hyperdrive-setup.md",
      "scripts/analyze_project.py"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/vercel-to-cloudflare"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/vercel-to-cloudflare",
    "agentPageUrl": "https://openagent3.xyz/skills/vercel-to-cloudflare/agent",
    "manifestUrl": "https://openagent3.xyz/skills/vercel-to-cloudflare/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/vercel-to-cloudflare/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Vercel to Cloudflare Worker Migration",
        "body": "Migrate a Next.js + Supabase project from Vercel to Cloudflare Workers with Hyperdrive connection pooling."
      },
      {
        "title": "Quick Start",
        "body": "Run the analysis script to scan the project:\npython3 scripts/analyze_project.py <project-path>\n\n\nReview the migration report\nRun the migration script:\npython3 scripts/migrate.py <project-path>\n\n\nConfigure Hyperdrive: see references/hyperdrive-setup.md"
      },
      {
        "title": "1. Install @opennextjs/cloudflare adapter",
        "body": "npm install @opennextjs/cloudflare\n\nUpdate next.config.js or next.config.ts if needed."
      },
      {
        "title": "2. Rewrite environment variable access",
        "body": "All process.env.XXX for Cloudflare bindings (Hyperdrive, KV, D1, etc.) must use getCloudflareContext():\n\n// BEFORE (Vercel/Node.js)\nconst url = process.env.DATABASE_URL;\n\n// AFTER (Cloudflare Worker)\nimport { getCloudflareContext } from '@opennextjs/cloudflare';\n\nfunction getConnectionInfo() {\n  const env = getCloudflareContext().env;\n  const hyperdrive = env.HYPERDRIVE as { connectionString?: string } | undefined;\n  if (hyperdrive?.connectionString) {\n    return { connectionString: hyperdrive.connectionString, source: 'hyperdrive' };\n  }\n  // Fallback for local dev\n  const local = env.CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE;\n  if (local) {\n    return { connectionString: local, source: 'hyperdrive-local' };\n  }\n  throw new Error('HYPERDRIVE is not configured');\n}"
      },
      {
        "title": "3. Refactor global DB singleton to per-request pattern",
        "body": "// BEFORE: Global singleton\nimport { drizzle } from 'drizzle-orm/postgres-js';\nimport postgres from 'postgres';\nconst client = postgres(process.env.DATABASE_URL!);\nexport const db = drizzle(client);\n\n// AFTER: Per-request with React cache\nimport { cache } from 'react';\n\nexport const getDb = cache(() => {\n  const { connectionString, source } = getConnectionInfo();\n  return createDatabase({\n    connectionString,\n    enableSSL: source === 'hyperdrive' ? false : 'require',\n  });\n});\n\nThen replace all import { db } with import { getDb } and add const db = getDb() at the start of each function."
      },
      {
        "title": "4. Configure wrangler.toml",
        "body": "name = \"my-app\"\nmain = \".open-next/worker.js\"\ncompatibility_date = \"2024-09-23\"\ncompatibility_flags = [\"nodejs_compat\"]\n\n[[hyperdrive]]\nbinding = \"HYPERDRIVE\"\nid = \"<your-hyperdrive-id>\""
      },
      {
        "title": "Critical Pitfalls",
        "body": "Hyperdrive must connect to Supabase Direct Connection (port 5432), NOT the Pooler (port 6543). Hyperdrive IS a connection pooler — connecting pooler-to-pooler causes errors.\n\n\nSSL must be disabled for Hyperdrive connections — Worker ↔ Hyperdrive is internal network. Only enable SSL for direct database connections (local dev, build stage).\n\n\nCannot initialize DB at module top level — getCloudflareContext() only works during request handling, not at module load time.\n\n\nSupabase Free Tier direct connection is IPv6 only — local dev may fail if your network doesn't support IPv6. Use the Pooler URL (port 6543) for local development."
      },
      {
        "title": "Detailed References",
        "body": "Hyperdrive setup & Supabase config: Read references/hyperdrive-setup.md\nEnvironment variable patterns: Read references/env-patterns.md"
      }
    ],
    "body": "Vercel to Cloudflare Worker Migration\n\nMigrate a Next.js + Supabase project from Vercel to Cloudflare Workers with Hyperdrive connection pooling.\n\nQuick Start\nRun the analysis script to scan the project:\npython3 scripts/analyze_project.py <project-path>\n\nReview the migration report\nRun the migration script:\npython3 scripts/migrate.py <project-path>\n\nConfigure Hyperdrive: see references/hyperdrive-setup.md\nCore Migration Steps\n1. Install @opennextjs/cloudflare adapter\nnpm install @opennextjs/cloudflare\n\n\nUpdate next.config.js or next.config.ts if needed.\n\n2. Rewrite environment variable access\n\nAll process.env.XXX for Cloudflare bindings (Hyperdrive, KV, D1, etc.) must use getCloudflareContext():\n\n// BEFORE (Vercel/Node.js)\nconst url = process.env.DATABASE_URL;\n\n// AFTER (Cloudflare Worker)\nimport { getCloudflareContext } from '@opennextjs/cloudflare';\n\nfunction getConnectionInfo() {\n  const env = getCloudflareContext().env;\n  const hyperdrive = env.HYPERDRIVE as { connectionString?: string } | undefined;\n  if (hyperdrive?.connectionString) {\n    return { connectionString: hyperdrive.connectionString, source: 'hyperdrive' };\n  }\n  // Fallback for local dev\n  const local = env.CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE;\n  if (local) {\n    return { connectionString: local, source: 'hyperdrive-local' };\n  }\n  throw new Error('HYPERDRIVE is not configured');\n}\n\n3. Refactor global DB singleton to per-request pattern\n// BEFORE: Global singleton\nimport { drizzle } from 'drizzle-orm/postgres-js';\nimport postgres from 'postgres';\nconst client = postgres(process.env.DATABASE_URL!);\nexport const db = drizzle(client);\n\n// AFTER: Per-request with React cache\nimport { cache } from 'react';\n\nexport const getDb = cache(() => {\n  const { connectionString, source } = getConnectionInfo();\n  return createDatabase({\n    connectionString,\n    enableSSL: source === 'hyperdrive' ? false : 'require',\n  });\n});\n\n\nThen replace all import { db } with import { getDb } and add const db = getDb() at the start of each function.\n\n4. Configure wrangler.toml\nname = \"my-app\"\nmain = \".open-next/worker.js\"\ncompatibility_date = \"2024-09-23\"\ncompatibility_flags = [\"nodejs_compat\"]\n\n[[hyperdrive]]\nbinding = \"HYPERDRIVE\"\nid = \"<your-hyperdrive-id>\"\n\nCritical Pitfalls\n\nHyperdrive must connect to Supabase Direct Connection (port 5432), NOT the Pooler (port 6543). Hyperdrive IS a connection pooler — connecting pooler-to-pooler causes errors.\n\nSSL must be disabled for Hyperdrive connections — Worker ↔ Hyperdrive is internal network. Only enable SSL for direct database connections (local dev, build stage).\n\nCannot initialize DB at module top level — getCloudflareContext() only works during request handling, not at module load time.\n\nSupabase Free Tier direct connection is IPv6 only — local dev may fail if your network doesn't support IPv6. Use the Pooler URL (port 6543) for local development.\n\nDetailed References\nHyperdrive setup & Supabase config: Read references/hyperdrive-setup.md\nEnvironment variable patterns: Read references/env-patterns.md"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/jiafar/vercel-to-cloudflare",
    "publisherUrl": "https://clawhub.ai/jiafar/vercel-to-cloudflare",
    "owner": "jiafar",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/vercel-to-cloudflare",
    "downloadUrl": "https://openagent3.xyz/downloads/vercel-to-cloudflare",
    "agentUrl": "https://openagent3.xyz/skills/vercel-to-cloudflare/agent",
    "manifestUrl": "https://openagent3.xyz/skills/vercel-to-cloudflare/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/vercel-to-cloudflare/agent.md"
  }
}