PDF Generation in Serverless Environments: Lambda, Vercel, Cloudflare
Why Puppeteer breaks in serverless, and how API-based PDF generation works perfectly with any serverless platform.
The serverless PDF problem
Serverless platforms (AWS Lambda, Vercel Functions, Cloudflare Workers) are designed for lightweight, stateless functions. Puppeteer is the opposite — it needs a 130MB+ Chromium binary, 200MB+ of RAM, and several seconds to cold-start.
The specific problems per platform:
AWS Lambda
Lambda has a 50MB deployment package limit (250MB unzipped). Chromium exceeds this. You need @sparticuz/chromium (a stripped-down build) deployed as a Lambda Layer. It works but is fragile, slow to cold-start (3-5s), and uses most of your memory allocation.
Vercel
Vercel functions have a 50MB bundle limit and 10-60 second timeouts. Chromium simply doesn't fit. Even with workarounds, you're fighting the platform instead of building your product.
Cloudflare Workers
Workers have a 1MB script limit and no filesystem. Puppeteer is completely impossible here.
API-based generation works everywhere
// Works on Lambda, Vercel, Cloudflare Workers, Deno Deploy, etc.
const res = await fetch('https://pdfrelay.com/api/v1/convert', {
method: 'POST',
headers: { 'Authorization': 'Bearer sk_live_...', 'Content-Type': 'application/json' },
body: JSON.stringify({ source: 'html', content: html }),
});
It's just an HTTP request. No binary dependencies, no memory issues, no bundle size problems. Works on every serverless platform, every edge runtime, every language. Your HTML and CSS skills are all you need — no browser engine, no proprietary format.