The whole integration
Node 18+ ships fetch, so there is nothing to install. The response body is the PDF itself.
import fs from "node:fs";
const res = await fetch("https://api.filecook.com/render/pdf", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.FILECOOK_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
html: "<h1>Invoice #1042</h1>",
options: { format: "A4", margin: "12mm" }
})
});
if (!res.ok) throw new Error(`Render failed: ${res.status}`);
fs.writeFileSync("invoice.pdf", Buffer.from(await res.arrayBuffer()));
What you delete when you switch
A Puppeteer-based service carries real operational weight. Moving the render off-box removes most of it.
- The ~300MB Chromium download and the Dockerfile layers that install its system libraries
- Browser lifecycle code — launch, page pooling, graceful shutdown, zombie process reaping
- The memory ceiling that forces you to restart workers on a timer
- Per-environment font installation, which is the usual cause of "it looked fine locally"
Streaming straight to a response
In Express or Fastify you rarely want the PDF on disk. Pipe it to the client, or hand the buffer to your S3 client and store it — the API returns raw bytes with a Content-Type of application/pdf, so both paths are one line.
Frequently asked questions
Do you publish an npm package?
Not required — the API is a plain HTTPS POST and native fetch covers it. An official SDK is on the roadmap for teams that prefer typed clients.
Does this work in serverless functions?
Yes, and it is the main reason teams switch. Chromium does not fit comfortably in most function size limits; an HTTPS call does.
Do you support modern CSS like Grid and Flexbox?
Yes. Filecook renders on the latest Chromium, so CSS Grid, Flexbox, custom properties, and modern selectors all behave exactly as they do in Chrome. If it looks right in your browser, it looks right in the PDF.
Can I use Google Fonts or my own web fonts?
Yes. Load them the normal way — an
@import in your stylesheet, a <link> tag, or a self-hosted @font-face rule. The renderer waits for fonts to load before it captures the page.Is there a free tier?
Yes — 500 renders a month, free forever, with no credit card required. That covers the playground, the full API, and both PDF and image output.
