Escape
HomeDocs@quario/docx

@quario/docx

The Word render target. Resolves the bytes of a .docx — an OOXML package, which is a zip — as a Uint8Array. Its one runtime dependency is fflate, confined to the module that writes the zip.

docx()

signature
function docx(options?: DocxOptions): Target<'docx', Promise<Uint8Array>>

interface DocxOptions {
  page?: { size?: 'A4' | 'letter' | [number, number]; margin?: number }
  meta?: { title?: string; author?: string; subject?: string }
}

Returns the target. It takes two options: page and meta. Any other key, or one of the wrong type, throws a TypeError naming the path. Nullish is absence at either level. page: null and meta: null are properties you didn’t write, and so is a meta whose one property is undefined. An inherited key is nobody’s option.

page is the PDF target’s, validated identically. size defaults to 'A4', and an array is a custom [width, height] in points. margin is points on all four sides, and defaults to 54 when the document declares none. A document declaring one and a host declaring another is a render error, as it’s there.

meta writes optional document properties — title, author and subject, strings only and never a date, so no clock reaches the package. The factory copies it as it reads it, so mutating that object afterwards changes nothing the target writes.

There is no fonts option and no stylesheet. A document is final when it opens, so what this target supplies where the author declared nothing, it supplies itself. The record the PDF target takes is therefore an error here rather than an option quietly lost.

A flow target

It’s a flow target: it states the geometry and the typography and lets Word paginate, so it runs no layout of its own. The promise is the same geometry and typography; where the pages break is the reader’s. That’s the deliberate difference from the PDF target, which paginates itself and can therefore promise where every line falls. The DOCX target →

Determinism

The same schema, data and options produce byte-identical output on every supported runtime. Every zip entry carries the same 1980-01-01 stamp, no part carries a clock, and docProps/core.xml has no slot for one.

A Word document, and Word paginates it.

npm install quario
Getting started
© 2026 quario · KvK 61815977