ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

vercel-to-cloudflare

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 costs, deploy to Cloudflare Workers, configure Hyperdrive connection pooling, or fix Supabase connectivity issues on Cloudflare. Triggers on phrases like "migrate to Cloudflare", "Vercel too expensive", "deploy Next.js on Cloudflare Worker", "Cloudflare Hyperdrive setup", "Supabase on Cloudflare", "从Vercel迁移到Cloudflare", "Vercel太贵了", "部署到Cloudflare Worker".

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/jiafar/vercel-to-cloudflare
Or

Vercel to Cloudflare Worker Migration

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

Quick Start

  1. Run the analysis script to scan the project:
    python3 scripts/analyze_project.py <project-path>
    
  2. Review the migration report
  3. Run the migration script:
    python3 scripts/migrate.py <project-path>
    
  4. Configure Hyperdrive: see references/hyperdrive-setup.md

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 variable 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 to per-request 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 = "<your-hyperdrive-id>"

Critical Pitfalls

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

  2. SSL must be disabled for Hyperdrive connections — Worker ↔ Hyperdrive is internal network. Only enable SSL for direct database connections (local dev, build stage).

  3. Cannot initialize DB at module top levelgetCloudflareContext() only works during request handling, not at module load time.

Metadata

Author@jiafar
Stars1947
Views0
Updated2026-03-04
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-jiafar-vercel-to-cloudflare": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.

Related Skills

amazon-scraper

High-performance containerized web scraper (Docker + Crawlee + Playwright). Use when user mentions any of these: 爬虫, 爬取, 抓取, 采集, 数据采集, 爬数据, 抓数据, 获取数据, scrape, crawl, extract, fetch data, pull data, 亚马逊, Amazon, ASIN, BSR, Best Sellers, 畅销榜, 热销榜, 新品榜, 飙升榜, 排行榜, 选品, 竞品分析, 竞品调研, 市场调研, 品类分析, 类目分析, 产品调研, 月销量, bought in past month, 销量, 评论数, 价格对比, YouTube, 视频字幕, 转录, transcript, 网页内容, 网站数据, 页面抓取, 动态页面, TikTok, Twitter, X, 社交媒体数据, 帖子内容, 关键词搜索, 搜索结果, search results, 产品详情, 产品信息, listing数据, listing分析, top 100, top sellers, 热门产品, 爆款, 跑量款, 价格带, 评分分布, review分析, 评论分析

jiafar 1947

horse-sticker-maker

Create and deploy a festive Chinese New Year (Year of the Horse 2026) animated GIF sticker maker web app. Use when the user wants to generate custom horse-themed blessing stickers, deploy a sticker generator H5 page, or create WeChat-compatible animated GIF stickers with gold horse animation on red background. Supports custom text input, 6-frame gold horse galloping animation, Canvas-based client-side GIF rendering via gif.js, and Vercel deployment.

jiafar 1947

google-patents

Search Google Patents database for patent research, infringement risk checks, and competitive IP analysis. Use when user mentions: 专利, patent, 侵权, infringement, 知识产权, IP, 外观设计, design patent, 专利检索, patent search, 专利风险, patent risk, 专利分析, patent analysis, 专利布局, patent portfolio, 有没有专利, 会不会侵权, 能不能卖, FTO, freedom to operate, 规避设计, 专利壁垒, 技术壁垒, 权利要求, claims, 专利详情, 发明人, inventor, 受让人, assignee, 专利号, patent number, 说明书, description, 技术领域, 背景技术, 发明内容, 具体实施方式, PDF

jiafar 1947

deep-scraper

High-performance containerized web scraper (Docker + Crawlee + Playwright). Use when user mentions any of these: 爬虫, 爬取, 抓取, 采集, 数据采集, 爬数据, 抓数据, 获取数据, scrape, crawl, extract, fetch data, pull data, 亚马逊, Amazon, ASIN, BSR, Best Sellers, 畅销榜, 热销榜, 新品榜, 飙升榜, 排行榜, 选品, 竞品分析, 竞品调研, 市场调研, 品类分析, 类目分析, 产品调研, 月销量, bought in past month, 销量, 评论数, 价格对比, YouTube, 视频字幕, 转录, transcript, 网页内容, 网站数据, 页面抓取, 动态页面, TikTok, Twitter, X, 社交媒体数据, 帖子内容, 关键词搜索, 搜索结果, search results, 产品详情, 产品信息, listing数据, listing分析, top 100, top sellers, 热门产品, 爆款, 跑量款, 价格带, 评分分布, review分析, 评论分析

jiafar 1947

clawprompt

Launch a smart teleprompter with mobile remote control for video recording. Use when the user wants to read scripts while recording video, use a teleprompter, or needs a prompter with phone remote control. Triggers on phrases like "open teleprompter", "start prompter", "提词器", "打开提词器", "录视频提词", "teleprompter", "提词", "I need a prompter", "read script while recording", "手机遥控提词", "ClawPrompt", "念稿子", "录视频看词", "对镜头念词". Features: dual-screen sync (computer + phone show same text), QR code phone pairing, mobile remote control (another person controls page turns), text upload from either device, fullscreen black-background white-text display, auto sentence segmentation, adjustable font size, countdown before start. Works with ClawCut — import AI-generated 9-scene scripts directly. 提词器, 智能提词器, teleprompter, 手机遥控, 视频录制辅助工具, prompter, autocue, 录制提词, 双屏同步, 远程翻页.

jiafar 1947