---
title: "@quario/docx — API reference"
description: "The Word render target for quario, covering the docx() factory, its page and meta options, and the bytes it resolves."
url: "https://getquario.com/docs/reference/docx"
---

# @quario/docx

The Word render target. It 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()`

```ts title="signature"
function docx(options?: DocxOptions): Target<'docx', Promise<Uint8Array>>

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

It 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](https://getquario.com/docs/reference/pdf.md), validated identically. `size`
defaults to `'A4'`, and an array is a custom `[width, height]` in points.
`margin` is points on all four sides, or each side named, and defaults to 54
when the document declares none. A document declaring a key and a host
declaring the same one is a render error, as it’s there. A document’s
`page.orientation` writes `w:orient`.

`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.

## `capabilities`

```ts title="signature"
const capabilities: {
  readonly target: 'docx'
  readonly declarations: Readonly<Record<string, Fate>>
}

type Fate = 'resolved' | 'approximated' | 'withdrawn' | 'unread'
```

What this target makes of each declaration the [support
matrix](https://getquario.com/docs/reference/support-matrix.md) names, keyed by the schema name an
author writes. Pass it to `plan(schema, functions, { targets })` to check a
document’s `required` marking before you render. It carries no version of its
own. The package that ships it sets the version.

## 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](https://getquario.com/docs/reference/pdf.md), which paginates itself
and can therefore promise where every line falls.
[The DOCX target →](https://getquario.com/docs/diving-deeper/docx-target.md)

## 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.

```json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://getquario.com/"},{"@type":"ListItem","position":2,"name":"Docs","item":"https://getquario.com/docs"},{"@type":"ListItem","position":3,"name":"@quario/docx","item":"https://getquario.com/docs/reference/docx"}]}
```
