JavaScript and React DOCX viewer/editor with pagination, editing, import/export, document review and thumbnails. It also opens legacy Word files and offers experimental, view-only support for OpenDocument text (.odt); see supported formats. The browser runtime uses the Rust/WASM parser from Duke Office.
pnpm add @extend-ai/react-docxReact integrations require react and react-dom; the /vanilla entry bundles Preact.
import { DocxEditorViewer, useDocxEditor } from "@extend-ai/react-docx";
export function DocumentViewer() {
const editor = useDocxEditor();
return (
<>
<input type="file" accept=".docx" onChange={(event) => {
const file = event.target.files?.[0];
if (file) void editor.importDocxFile(file);
}} />
<DocxEditorViewer editor={editor} mode="read-only" defaultZoom="fit-width" />
</>
);
}Use mode="edit" for editing and editor.exportDocx() for export. For a parsed document, use useDocxEditor({ document }). Vanilla apps use createDocxViewer from @extend-ai/react-docx/vanilla and call destroy() on teardown.
Full API and hooks · Vanilla API · Thumbnails
- WASM loads lazily. Configure
setWasmSourcebefore the first parse/export for custom hosting; see WASM and Vite setup. - Built-in imports require a same-origin Web Worker by default. Pass
useWorkertouseDocxEditororuseDocxModelto permit or force main-thread parsing;parseDocxForViewerpermits main-thread fallback unlessuseWorker: "required"is set. Layout and React rendering run on the main thread. See import worker. - Embedded fonts load by default. After changing caller fonts, call
refreshDocxFontMetrics(); recreate standalone thumbnail renderers. See font handling. - Review mutations support limited text revisions and plain-text comment ranges. Unsupported or stale actions leave the document unchanged; review hooks and boundaries describe the contract.
- OpenDocument text support (
.odt,.ott,.odm,.otm,.oth, flat.fodt) is experimental and view-only; rendering coverage and layout fidelity may vary.editor.viewOnlyReasonis set, the viewer renders read-only in anymode, andexportDocx()/getDocxBytes()are refused. What is and is not displayed. - Saved 3D previews remain visible;
parseDocxForViewer(source, { include3dModels: true })additionally exposes original assets and scene XML. Shared renderer coverage distinguishes rendering from preserved previews.
Use Node.js from .nvmrc and pnpm 9.15.0; supported Node ranges are in package.json.
pnpm install --frozen-lockfile
pnpm dev
pnpm build
pnpm typecheck
pnpm test:unit
pnpm test:visual| Work | Start here |
|---|---|
| Public viewer, controller and hooks | packages/react-viewer |
| OOXML parts and normalized model | packages/ooxml-core, packages/doc-model |
| Editing and DOCX export | packages/editor-ops, packages/serializer |
| Pagination and layout | packages/layout-engine, packages/layout-core |
| WASM build and Rust adapter | packages/wasm, crates/docx-wasm |
| Manual and automated validation | apps/playground, tests, Word fidelity harness |
Parser fixes belong in Duke Office. Normal JS builds validate the committed WASM; runtime updates must include rebuilt bindings, lockfiles, provenance and notices. npm releases use Changesets; Rust and npm versions are independent. See playground deployment for build provenance.
November 4, 2026, React DOCX 0.14.0: 155/157 charts rendered, with 28 pairs in this overview. Galleries, measurements and method retain differences and missing charts. Parser benchmarks measure native extraction separately from viewer layout.
November 6, 2026: 30 native-adapter cases covering SmartArt, WordArt, 3D previews, shapes, icons and ink. These captures measure the shared renderer, not this npm release's pagination. Font substitution, curved text, shading and pencil texture remain limited.
WordArt and 3D shapes · Models and SmartArt · Icons and ink · Method and remaining gaps
Click the screenshots for viewer/editor demos and integration docs. MIT license.



