Skip to main content

Installation

Install the package​

npm install docxio
# or
bun add docxio

Configure TypeScript​

Add the JSX import source to your tsconfig.json:

{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "docxio"
}
}

This tells TypeScript to use docxio's JSX factory instead of React's. No React dependency is needed.

Backend selection​

docxio ships with three WASM backends. The default "auto" mode works for most projects.

BackendWASM SizeZIP handlingBest for
"minimal"441 KBJS-side (@docxio/zip)Browser -- smallest bundle
"full"920 KBRust-sideServer -- includes parser, template engine, validator
"auto" (default)----Tries minimal first, falls back to full

To force a specific backend:

import { render } from "docxio";

const bytes = await render(doc, { backend: "minimal" });

Optional packages​

Install additional packages depending on your use case:

PackagePurpose
@docxio/htmlHTML and Markdown export
@docxio/bunBun build plugin
@docxio/nodeNative Node.js bindings via napi-rs
@docxio/zipJS-side ZIP assembly (used by minimal backend)
@docxio/wasm-minimalMinimal WASM binary (XML only)
# Example: add HTML export
npm install @docxio/html

Verify installation​

Create a file called hello.tsx and run it:

/** @jsxImportSource docxio */
import { render } from "docxio";

const doc = (
<document title="Test">
<section>
<paragraph><run>It works!</run></paragraph>
</section>
</document>
);

const bytes = await render(doc);
console.log(`Generated ${bytes.length} bytes`);