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

OptionTypeDescription
variablesRecord<string, VariableValue>Dynamic data passed to Variable components and useVariables
strictbooleanThrow StrictModeError if any error-severity diagnostic is emitted
tailwindParserTailwindParserCustom parser for overriding colors, fonts, or adding class handlers

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

CodeSeverityDescription
IMAGE_LOAD_FAILEDerrorImage file not found or URL unreachable
INVALID_NESTINGerrorComponent placed in an unsupported parent
UNSUPPORTED_TAILWIND_CLASSwarningTailwind class has no DOCX equivalent
TAILWIND_CONFIG_LOAD_FAILEDwarningFailed to parse tailwind.config file
VARIABLE_NOT_FOUNDinfoVariable not provided and no defaultValue set

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