deploying-payload-to-cloudflare

Installation
SKILL.md

Deploying Payload CMS to Cloudflare Workers

Overview

Deploying Payload CMS to Cloudflare Workers often hits the 3 MiB bundle size limit and encounters issues with native dependencies like sharp and @vercel/og. This skill provides a proven strategy to overcome these limitations by pruning unused files and patching imports.

When to Use

  • Deploying Payload CMS to Cloudflare Workers.
  • Encountering "Bundle size exceeds 3 MiB" errors.
  • Encountering "Could not resolve" errors for sharp, resvg.wasm, or yoga.wasm.

The Strategy

  1. Build: Use @opennextjs/cloudflare to build the worker.
  2. Prune: Remove the massive node_modules directory from the output. The worker bundle (handler.mjs) already contains the necessary code (mostly).
  3. Patch: Replace absolute paths to missing native modules (which were in the pruned node_modules) with an empty module stub.

Risks & Trade-offs

Installs
8
GitHub Stars
12
First Seen
Jun 6, 2026