npm install @cordel/react-docx
pnpm add @cordel/react-docx
yarn add @cordel/react-docx
bun add @cordel/react-docx
@types
{ "compilerOptions": { "jsx": "react-jsx", "moduleResolution": "bundler" } }
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
test.docx
Was this page helpful?