Skip to main content
npm install @cordel/react-docx
Requires React 18+.

TypeScript

Types are included. No @types package needed.
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "moduleResolution": "bundler"
  }
}

Quick check

import { Document, Section, Paragraph } from "@cordel/react-docx";
import { renderToBuffer } from "@cordel/react-docx";
import fs from "node:fs";

const Doc = () => (
  <Document>
    <Section>
      <Paragraph>It works.</Paragraph>
    </Section>
  </Document>
);

const buffer = await renderToBuffer(<Doc />);
fs.writeFileSync("test.docx", buffer);
npx tsx test.tsx
If test.docx opens in Word, you’re good.