secondsky/claude-skills / plugins/cloudflare-nextjs/skills/cloudflare-nextjs
cloudflare-nextjs
VerifiedDeploy 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 20.7 KB |
| assets/workflow-diagram.md | markdown | 15.8 KB |
| references/advanced.md | markdown | 10.0 KB |
| references/bindings-and-services.md | markdown | 6.7 KB |
| references/caching.md | markdown | 6.4 KB |
| references/database-client-example.ts | script | 3.8 KB |
| references/dev-deploy-and-env.md | markdown | 3.7 KB |
| references/error-catalog-extended.md | markdown | 7.5 KB |
| references/feature-support.md | markdown | 13.2 KB |
| references/known-issues.md | markdown | 2.1 KB |
| references/open-next.config.ts | script | 7.3 KB |
| references/package.json | manifest | 871 B |
| references/troubleshooting.md | markdown | 4.3 KB |
| references/wrangler.jsonc | other | 6.1 KB |
| scripts/analyze-bundle.shexecutable | script | 3.9 KB |
| scripts/setup-existing-project.shexecutable | script | 3.1 KB |
| scripts/setup-new-project.shexecutable | script | 1.1 KB |
scripts/analyze-bundle.sh
View on GitHub#!/bin/bash
# Analyze Next.js Worker bundle size to debug worker size limit errors
set -e
echo "π Analyzing Worker bundle size..."
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
# Check if @opennextjs/cloudflare is installed
if ! grep -q "@opennextjs/cloudflare" package.json; then
echo "β Error: @opennextjs/cloudflare is not installed."
echo "Run: npm install --save-dev @opennextjs/cloudflare"
exit 1
fi
# Build the project
echo "π¨ Building Next.js project with OpenNext adapter..."
npx opennextjs-cloudflare build
# Check if build succeeded
if [ ! -d ".open-next" ]; then
echo "β Error: Build failed - .open-next directory not found"
exit 1
fi
# Navigate to build output
cd .open-next/server-functions/default
echo ""
echo "β
Build complete!"
echo ""
echo "π Build output location:"
echo " .open-next/server-functions/default/"
echo ""
# Check if handler exists
if [ ! -f "handler.mjs" ]; then
echo "β Error: handler.mjs not found in build output"
exit 1
fi
# Get file sizes
HANDLER_SIZE=$(stat -f%z "handler.mjs" 2>/dev/null || stat -c%s "handler.mjs" 2>/dev/null || echo "unknown")
HANDLER_SIZE_MB=$(echo "scale=2; $HANDLER_SIZE / 1048576" | bc 2>/dev/null || echo "unknown")
echo "π¦ Worker Bundle Size:"
echo " handler.mjs: $HANDLER_SIZE bytes (~${HANDLER_SIZE_MB} MiB uncompressed)"
echo ""
echo "π Cloudflare Worker Size Limits:"
echo " Free plan: 3 MiB (gzip-compressed)"
echo " Paid plan: 10 MiB (gzip-compressed)"
echo ""
# Check for bundle metadata
if [ -f "handler.mjs.meta.json" ]; then
echo "π Bundle Metadata:"
echo " File: handler.mjs.meta.json"
echo ""
echo "To analyze bundle composition:"
echo " 1. Open handler.mjs.meta.json in ESBuild Bundle Analyzer"
echo " 2. Identify large dependencies"
echo " 3. Consider:"
echo " - Removing unused dependencies"
echo " - Using dynamic imports for code splitting"
echo " - Externalizing large packages if possible"
echo ""
else
echo "β οΈ Bundle metadata (handler.mjs.meta.json) not found"
echo ""
fi
# List all files in build output
echo "π Build Output Contents:"
ls -lh
echo ""
# Check for common large dependencies
echo "π Checking for common large dependencies..."
if [ -f "handler.mjs" ]; then
# Check for common problematic imports (this is a simple check)
LARGE_DEPS=()
if grep -q "prisma" handler.mjs 2>/dev/null; then
LARGE_DEPS+=("@prisma/client")
fi
if grep -q "aws-sdk" handler.mjs 2>/dev/null; then
LARGE_DEPS+=("aws-sdk")
fi
if grep -q "firebase" handler.mjs 2>/dev/null; then
LARGE_DEPS+=("firebase")
fi
if grep -q "graphql" handler.mjs 2>/dev/null; then
LARGE_DEPS+=("graphql")
fi
if [ ${#LARGE_DEPS[@]} -gt 0 ]; then
echo "β οΈ Found potentially large dependencies:"
for dep in "${LARGE_DEPS[@]}"; do
echo " - $dep"
done
echo ""
echo "Consider:"
echo " - Using lighter alternatives"
echo " - Dynamic imports to reduce initial bundle"
echo " - Moving heavy operations to separate Workers"
echo ""
else
echo "β
No obviously large dependencies detected"
echo ""
fi
fi
echo "π‘ Tips to Reduce Bundle Size:"
echo " 1. Remove unused dependencies from package.json"
echo " 2. Use dynamic imports: const module = await import('heavy-module')"
echo " 3. Split large features into separate routes/pages"
echo " 4. Check for duplicate dependencies (npm dedupe)"
echo " 5. Consider using lighter alternatives for heavy packages"
echo " 6. Review handler.mjs.meta.json for detailed breakdown"
echo ""
echo "π More info:"
echo " https://opennext.js.org/cloudflare/troubleshooting#worker-size-limits"
echo ""
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 119k | Updated | Claude CodeCodex | Verified | Install |
| 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: 118k | Updated | Claude CodeCodex | Verified | Install |