Skip to content

Serverless / Vercel

Nebula targets Node.js servers. It depends on native addons:

  • sharp
  • @resvg/resvg-js

Those packages do not run in the browser or typical Edge/WASM runtimes.

  1. Use a Node.js runtime (e.g. Vercel Node serverless functions / App Router runtime = 'nodejs').
  2. Bundle or include platform-correct native binaries for your deploy OS/arch (Linux x64 is common on Vercel).
  3. Watch memory and timeout — large tables and high devicePixelRatio increase PNG size and work.
  4. Prefer embedding fonts as Buffers loaded at cold start (or from the function bundle), not from remote URLs on every request.
  5. Keep devicePixelRatio at 1 or 2 for colder / smaller functions.
export const runtime = 'nodejs';
export const maxDuration = 30;
// Same pattern as Next.js: engine.generate → Response(pdf, { headers })
  • Edge Middleware / Edge Functions
  • Cloudflare Workers without a Node-compatible native strategy
  • Bundlephobia-style “browser bundle size” metrics (native deps cannot be browser-bundled)