Edge
Deploy Format to edge runtimes like Cloudflare Workers and Deno Deploy.
Edge runtimes like Cloudflare Workers and Deno Deploy can generate PDFs using Format. Use the worker target to produce a fully self-contained bundle with all dependencies included.
Compiling for edge
npx format compile --preset edgeThe edge preset sets the worker target and bundles all dependencies. The output avoids Node.js-specific APIs and targets Web Worker environments.
Assets
Edge runtimes cannot read from the filesystem. Upload your asset ZIPs to a CDN or object storage and point to them at runtime using setAssetsUrl.
invoice.setAssetsUrl('https://cdn.example.com/assets/invoice/assets.zip')
const doc = await invoice.render(data)
const format = new FormatClient()
const response = await format.pdf(doc)Call setAssetsUrl before render(). The URL should point to the assets.zip for that document.
See Assets for more on uploading and versioning asset ZIPs.
Cloudflare Workers
Compile with the edge preset and deploy using Wrangler:
npx format compile --preset edge
wrangler deployUpload your asset ZIPs to an R2 bucket and connect it to a custom domain or public URL. Then reference the URL in your worker:
invoice.setAssetsUrl('https://assets.example.com/invoice/assets.zip')See Assets for upload examples and cache headers.
Deno Deploy
Compile with the edge preset. The self-contained bundle works with Deno's module system:
npx format compile --preset edgeHost asset ZIPs on any CDN or object storage accessible from the edge.
Dependencies
The worker target bundles all dependencies by default. No external packages to install. Use --external to exclude packages your runtime already provides:
npx format compile --preset edge --external some-runtime-provided-package