Skip to main content
Returns a Promise<RenderResult> with the output path and any diagnostics collected during rendering.

Basic usage


renderToBuffer

For serverless or HTTP scenarios where you don’t want to write to disk:
Returns a Promise<RenderToBufferResult> with a Uint8Array buffer and diagnostics.

HTTP response

Write to file manually


Variables

Pass dynamic data to your document:

Variable component

useVariables hook

For more control:

Formatting


Render options


Diagnostics

Both render and renderToBuffer return a diagnostics array. These are structured warnings and errors collected during rendering — images that failed to load, invalid nesting, unsupported Tailwind classes, etc.

Diagnostic interface

Common codes

Custom handler

Override how diagnostics are reported:
Pass null to restore the default console-based handler:

Strict mode

Throws a StrictModeError if any diagnostic with "error" severity is emitted:
Works with renderToBuffer too:

Error handling

Three levels of error handling: Diagnostics — non-fatal issues returned in the result. The document still generates.
Strict mode — promote error-severity diagnostics to thrown exceptions.
Try/catch — handle unexpected failures (invalid JSX tree, filesystem errors, etc.).

Full example