Skip to content

secondsky/claude-skills / plugins/cloudflare-nextjs/skills/cloudflare-nextjs

cloudflare-nextjs

Verified

Deploy Next.js to Cloudflare Workers via the OpenNext adapter (@opennextjs/cloudflare). Use for SSR/ISR/SSG/App or Pages Router, getCloudflareContext, bindings (D1/R2/KV/AI/Hyperdrive), caching tiers, skew protection, multi-worker, custom worker, env vars, or worker size/runtime/keep_names/FinalizationRegistry/connection-scoping errors.

scripts/setup-existing-project.sh

View on GitHub
#!/bin/bash
# Add OpenNext Cloudflare adapter to an existing Next.js project.
#
# Preferred: use the adapter's own `migrate` command, which automates
# installing deps, creating wrangler.jsonc / open-next.config.ts / .dev.vars,
# wiring package.json scripts, adding public/_headers, .gitignore, the
# `initOpenNextCloudflareForDev()` call in next.config.ts, and an R2 cache
# bucket (if R2 is enabled on the account).
#
# Docs: https://opennext.js.org/cloudflare/get-started
#       https://opennext.js.org/cloudflare/cli

set -e

echo "πŸ”§ Adding OpenNext Cloudflare adapter to existing Next.js project"
echo ""

# Check if we're in a Next.js project
if [ ! -f "package.json" ]; then
    echo "❌ Error: No package.json found. Run this script from your Next.js project root."
    exit 1
fi

if ! grep -q "\"next\":" package.json; then
    echo "⚠️  Warning: Next.js doesn't appear to be installed in package.json"
    echo "Are you sure this is a Next.js project?"
    read -p "Continue anyway? (y/N) " -n 1 -r
    echo
    if [[ ! $REPLY =~ ^[Yy]$ ]]; then
        exit 1
    fi
fi

# Preferred path: adapter migrate command
echo "πŸš€ Running: npx @opennextjs/cloudflare migrate"
echo "   (installs deps, creates configs, wires scripts, sets up R2 cache if enabled)"
echo ""
npx @opennextjs/cloudflare@latest migrate

# Check for Edge runtime usage
echo ""
echo "πŸ” Checking for Edge runtime usage..."
if grep -r "export const runtime = \"edge\"" app/ pages/ src/ 2>/dev/null; then
    echo "⚠️  WARNING: Found Edge runtime exports!"
    echo "   OpenNext requires the Node.js runtime. Remove 'export const runtime = \"edge\"' from your files."
else
    echo "βœ… No Edge runtime exports found"
fi

# proxy.ts caveat (Next 16)
echo ""
echo "πŸ“Œ Next 16 note: if you renamed middleware.ts β†’ proxy.ts, rename it back."
echo "   @opennextjs/cloudflare does not yet recognize proxy.ts (issue #1277)."

echo ""
echo "βœ… Setup complete!"
echo ""
echo "Next steps:"
echo "  1. npm run dev      # Next.js dev server (fast HMR)"
echo "  2. npm run preview  # Run in the Workers runtime (REQUIRED before deploy)"
echo "  3. npm run deploy   # Build + deploy to Cloudflare"
echo ""
echo "πŸ“– Documentation: https://opennext.js.org/cloudflare"
echo "πŸ› Open issues:    https://github.com/opennextjs/opennextjs-cloudflare/issues"
echo ""

# ─────────────────────────────────────────────────────────────────────────────
# FALLBACK: manual install (uncomment if you prefer not to use `migrate`)
# ─────────────────────────────────────────────────────────────────────────────
# npm install @opennextjs/cloudflare@latest
# npm install --save-dev wrangler@latest
# # Then create wrangler.jsonc, open-next.config.ts, .dev.vars, and add the
# # dev/preview/deploy/upload/cf-typegen scripts β€” see the skill's references/.
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path β€” even casually (like "the xlsx in my downloads") β€” and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall