Promise<string> with the output path.
To keep the document in memory, for example to send it in an HTTP response or upload it, use renderToBuffer. It resolves to the file’s bytes as a Uint8Array:
For documents rendered from data that comes from outside the program, see Templates and testing.
Basic usage
Variables
Pass dynamic data to your document:Variable component
Variable that is not in variables and has no defaultValue rejects the render, so a missing value cannot produce an incomplete document. Pass null to render it empty on purpose.
useVariables hook
For more control:Formatting
Async data
Components can read promises with React’suse() or load with React.lazy. Rendering waits until every suspended component has its data, so the document never contains a Suspense fallback.
render().
Error handling
render() and renderToBuffer() reject, without writing a file, when:
- a component throws and no error boundary catches it;
- a
<Variable>was not provided and has nodefaultValue; - an image cannot be loaded or is not PNG, JPEG, GIF or BMP;
- an element is placed where Word cannot represent it, such as a
<Section>outside<Document>or a<Paragraph>inside a<Link>.
