RebodocsDocs
Start3
What is Rebodocs
Getting started
Demos to run
Put it in your app8
React component
Headless: your own UI
A complete interface
Without a framework
Only to read: the viewer
Styling and Tailwind
Phones and touch
Accessibility
Documents8
Templates and variables
On a server: DOCX and PDF
Documents in an S3 bucket
Letterheads
Versions
Tracked changes
Fonts
Languages
Together2
Real-time collaboration
AI assistants (MCP)
Reference5
Packages
Components and hooks
Editor API
How it works
Status and roadmap
↑↓ to move↵ to openEsc to close26 pages

Start Getting started

Getting started

Every package is on npm: @rebodocs/react for React and Next.js, and the engine, the editor without a framework, collaboration and the tools for an assistant by themselves. Packages says which to take.

tip: the example below is running — save it
React

Put it in a React application

One package, with the engine, the editor and the collaboration client inside. React 18 or later is its peer.

Use the component. The element it is in must have a height:

'use client';
import { DocsEditor } from '@rebodocs/react';

export default function Page() {
  return (
    <div style={{ height: '100vh' }}>
      <DocsEditor name="untitled.docx" locale="en" onSave={(docx, name) => console.log(name, docx.byteLength)} />
    </div>
  );
}

That gives an empty document. To open a file, pass its bytes as docx. Here it is, as written:

Opening the editor…

Open a file and save it back

The editor keeps nothing: it is given the bytes, and gives them to onSave when the person saves. Where they come from and where they go is your application’s:

'use client';
import { DocsEditor } from '@rebodocs/react';
import { useEffect, useState } from 'react';

export default function Contract() {
  const [file, setFile] = useState<Uint8Array>();

  useEffect(() => {
    fetch('/api/contract')
      .then((response) => response.arrayBuffer())
      .then((bytes) => setFile(new Uint8Array(bytes)));
  }, []);

  if (!file) return <p>Opening…</p>;
  return (
    <div style={{ height: '100vh' }}>
      <DocsEditor
        docx={file}
        name="contract.docx"
        onSave={async (docx) => {
          const response = await fetch('/api/contract', { method: 'PUT', body: docx });
          if (!response.ok) throw new Error(response.statusText);
        }}
      />
    </div>
  );
}
  • Keep the bytes in state. docx is compared as an object: another array, even with the same bytes, is another document, and the editor opens it again and loses what was edited.
  • When onSave throws, the person is told the save failed and the document stays unsaved. fetch does not throw on an error of the server, hence the check.
  • On a server it renders an empty element, and mounts in the browser. Every prop is in React component.
  • Without locale, the interface is in the first of the browser’s languages it speaks, or in English.
  • No React? The same package has the whole editor without it: import { mountDocs } from '@rebodocs/react/mount', and npm does not install React for it, as it is an optional peer. See Without a framework.
Node

Use the engine in Node

To fill templates or make PDFs on a server, with no browser and no editor: the engine is a package of its own.

// fill.mjs
import { readFileSync, writeFileSync } from 'node:fs';
import { exportDocx, fillVariables, importDocx, variableNames } from '@rebodocs/core';

const template = importDocx(new Uint8Array(readFileSync('template.docx')));
const doc = fillVariables(template, { client: 'Ana Pérez' });
console.log('Left as they are:', variableNames(doc));
writeFileSync('out.docx', exportDocx(doc));
node fill.mjs

The engine is the same in the browser, so here is that script, run on the agreement of the demo:

Reading the template…

A variable without a value stays as it is written. Dates and amounts are written in the language of the document, or in English when it says none, unless locale says another.

Or, with no code, the command that comes with @rebodocs/mcp: it lists the variables of a template, fills it from a JSON file into a DOCX, a PDF or Markdown, and says what it left.

npx -p @rebodocs/mcp rebodocs-generate template.docx --list
npx -p @rebodocs/mcp rebodocs-generate template.docx data.json -o out.pdf

A PDF, its fonts, and the rest are in On a server.

Next

Where to go next

Repository

Run the repository

To try everything, to change the code, or to run the demos. It needs Node 22.12 or later.

git clone https://github.com/JFranciscoRobles/rebodocs.git
cd rebodocs
npm install
npm run dev

Open http://localhost:5173. That is the playground: the editor with everything switched on. Open a Word file from the menu and edit it.

Inside the repository the packages import each other as TypeScript source, with no build: a script of your own runs with npx vite-node.

Commands

Commands

Every script of the repository, from its root.

Run
npm run dev
The playground: the editor with everything switched on, with hot reload, at localhost:5173.
npm run demo
The React package, two ways: the whole component, and an interface of its own on the hooks.
npm run storage
Documents in an S3 bucket, with versions.
npm run realtime
Several people on one document.
npm run assistant
Claude in a shared document; needs a key of the Claude API.
npm run crm
The editor inside a CRM: documents made from a template with the data of a record.
npm run desktop
The desktop application, with Tauri; needs Rust.
npm run site
This website, at localhost:5174, after building @rebodocs/react.
Check
npm test
The tests, with Vitest.
npm run test:browser
The editor itself on a page, in a Chrome without a window: keys, clicks, touches and the clipboard.
npm run typecheck
Types, over every package and every demo.
npm run lint · format
Biome: says what is wrong, or writes it right.
npm run coverage
The tests, with what of the packages they reach.
npm run api -- --check
Whether packages/core/API.md, the public API of the engine as it stands, is out of date; without --check it writes it again.
npm run a11y -- <url>
axe on pages with the editor in them, in a Chrome without a window: what breaks WCAG 2.2 A and AA.
npm run word-check
The documents of test-documents/ laid out and compared, line by line, with the PDF Word made of each; fails when one is worse than before. Needs Chrome and pdftotext, not Word.
npm run word-compare -- file.docx
The editor's layout of a file against Microsoft Word's, line by line; --word has Word make its PDF, on macOS.
npm run float-cases · contract-cases
Writes the documents of test-documents/ that measure floating pictures and long contracts against Word.
npm run bench
How long the engine takes on a long document: layout, DOCX, comparing, PDF. Run it before and after a change.
npm run eval:assistant
The assistant beside the editor, on cases of its own, with the real Claude API; needs a key.
Tools
npm run generate -- template.docx data.json -o out.pdf
Fills a template without a browser, into a DOCX, a PDF or Markdown; npx -p @rebodocs/mcp rebodocs-generate outside the repository.
npm run collab
The collaboration server; npx @rebodocs/collab outside the repository.
npm run mcp
The MCP server for AI assistants; npx @rebodocs/mcp outside the repository.
npm run locale -- fr texts/fr.json
Starts or updates a translation of the interface.
Build
npm run build:react
Builds @rebodocs/react and packs it into packages/react.
npm run build:packages
Builds core, editor, collab and mcp, each into its dist/; build:mcp only the last.
npm run build:site
This website, as static files.
npm run build · build:demo · build:desktop
The playground, the React demo and the desktop application.