
I replaced a Puppeteer service with 39 lines of code
I had a separate Express server running headless Chrome just to generate PDFs. It was slow, expensive, and crashed under load. I replaced the entire thing with a single function call. Here's what happened. The setup I run a soil analysis API. Farmers submit samples, the API processes results, and generates a 4-page PDF report - cover page, nutrient analysis tables, product recommendations, the works. The PDF pipeline looked like this: A 700-line function in pdf-generator.ts builds an HTML string — concatenating divs, inline styles, table rows, all of it POST that HTML to a separate Express server running Puppeteer Puppeteer launches headless Chrome, renders the HTML, calls page.pdf() Upload the PDF bytes to Vercel Blob Return the URL It worked. Mostly. The problems It was slow. Each render took 1–5 seconds depending on Chrome's mood. Cold starts were worse. It needed its own server. Chromium is 200MB+. Vercel functions have a 50MB bundle limit. So I ran a separate server just to host h
Continue reading on Dev.to React
Opens in a new tab



