Private betav0.3.0
DocsSign in
Format developer documentation

Serverless

Deploy Format to serverless functions.

Serverless platforms like AWS Lambda, Google Cloud Functions, and Azure Functions can generate PDFs using Format. Bundle the _generated directory into your deployment package alongside your function code.

AWS Lambda

Compile your documents and include the _generated directory in your Lambda deployment package:

npx format compile
zip -r function.zip dist/ _generated/ node_modules/ package.json

The node target works out of the box. Lambda functions have filesystem access, so format.pdf(doc) reads assets automatically.

Lambda@Edge / CloudFront Functions

For Lambda@Edge, use the worker target. Asset ZIPs must be hosted externally since Lambda@Edge has limited filesystem access and strict size limits:

npx format compile --preset edge

Upload assets.zip files to S3 and call setAssetsUrl at runtime. See Assets for details.

Google Cloud Functions

Same pattern as AWS Lambda. Compile, include _generated in your deployment, and use the node target:

npx format compile
gcloud functions deploy generate-pdf --runtime nodejs20 --trigger-http

Dependencies

The node target externalizes dependencies by default. Ensure your framework packages (react, react-dom or vue) are installed in your deployment package.

To reduce package size, bundle dependencies directly:

npx format compile --bundle date-fns @company/shared-utils
Was this page helpful?