Reference Packages
Packages
Six packages, each for one thing, all on npm at the same version, 0.13.0. Most applications need one.
Which one do I install?
Pick what you are making. The drawing shows what you install, what comes inside it, and who uses whom.
One install: the engine, the editor and the collaboration client come inside.
One engine, not two. @rebodocs/react is built as one file with the engine, the editor and the collaboration client inside. The others ask npm for @rebodocs/core and share one copy of it, so a Doc made with core is the one they take. An application that installs both @rebodocs/react and @rebodocs/core has the engine twice.
Where each one runs
The six side by side: where each runs, what it is built for, and what it brings with it.
- All six:
- ESM only
- TypeScript types included
- Tree-shakeable
- MIT
@rebodocs/editor@rebodocs/coreReact 18+ (optional peer)@rebodocs/core@rebodocs/core@anthropic-ai/sdkSame version, all of them. Every package is published at the same version, and they expect each other at it: update them together. Rebodocs is 0.x and pre-release, so a new version may change an API; what is done and what is coming is in Status and roadmap.
The packages
One at a time: how to get it, what it has, and the least code that uses it.
@rebodocs/react
ReactREADME →On npm →The editor for React: the whole of it as one component, or the pages and hooks to draw your own.
- Browser
- Safe to render on a server
- ES2022 browsers
Get it
Depends on
React 18+ (peer)What is inside
- DocsEditor
- The whole editor as a component: toolbar, ruler, side panel, pages, status bar.
- DocsProvider, DocsSurface, hooks
- The pages, and thirteen hooks to build an interface of your own.
- mountDocs, createDocs
- The same two, with no React in them.
- DocsViewer
- A document only to read, the component of @rebodocs/viewer.
- Built in
- The engine, the editor, the viewer and the collaboration client, in one bundle.
Import it from
- @rebodocs/react
- The components, the hooks, createDocs, languages and fonts.
- @rebodocs/react/mount
- mountDocs: the whole editor in an element, without React.
Take it
For a React or Next.js application. It is the one an application installs first.
Use it
'use client';
import { DocsEditor } from '@rebodocs/react';
export function Contract({ file }: { file: Uint8Array }) {
return (
<div className="h-screen">
<DocsEditor docx={file} name="contract.docx" locale="en" onSave={(docx, name) => upload(docx, name)} />
</div>
);
}@rebodocs/editor
No frameworkREADME →On npm →The editor in the browser with no framework: the Editor class and its interface, piece by piece.
- Browser
- ES2022 browsers
Get it
Depends on
@rebodocs/coreWhat is inside
- Editor
- Pages, caret, selection, history, keyboard, mouse and touch.
- Interface pieces
- createToolbar, createStatusBar, createRuler, createPanel, createFindBar, createBubble, createSlashMenu, createVariableSuggest: each in an element of yours, or over the page.
- Languages and fonts
- setLocale, addLocale, addFonts; Chinese in @rebodocs/editor/locales.
Import it from
- @rebodocs/editor/locales/zh-Hans
- The interface in Simplified Chinese, for addLocale.
- @rebodocs/editor/locales/zh-Hant
- The interface in Traditional Chinese, for addLocale.
Use it
import { Editor, createToolbar, createStatusBar, createBubble } from '@rebodocs/editor';
const editor = new Editor(document.querySelector('#pages')!);
createToolbar(document.querySelector('#toolbar')!, editor);
createStatusBar(document.querySelector('#status')!, editor);
createBubble(editor);
editor.loadDocx(bytes);
const pdf = await editor.exportPdf('Contract');@rebodocs/viewer
Read onlyREADME →On npm →A document only to read: the pages of the editor read only, a bar to zoom and print, and the first page as a thumbnail.
- Browser
- Safe to render on a server (React)
- ES2022 browsers
Get it
Depends on
@rebodocs/editor@rebodocs/coreReact 18+ (optional peer)What is inside
- createViewer
- The document in an element, from the bytes of a .docx: one page under another, or all at once; print().
- DocsViewer
- The same as a React component, in @rebodocs/viewer/react.
- pagePicture, pageThumbnail
- The first page as a JPEG or a PNG, or as the element the editor draws.
Import it from
- @rebodocs/viewer/react
- DocsViewer: the viewer as a React component.
Take it
For an application that shows documents and does not edit them: a file manager, a preview, a page that shows a contract.
Use it
import { createViewer, pagePicture } from '@rebodocs/viewer';
const viewer = createViewer(document.querySelector('#pages')!, bytes);
viewer.setLayout('all');
const thumbnail = await pagePicture(bytes, 480); // a JPEG@rebodocs/core
No DOMREADME →On npm →The engine: everything about a document that does not need a screen.
- Node
- Browser
- ES2022: Node and browsers
Get it
Depends on
fflateWhat is inside
- Model
- An immutable Doc of paragraphs, runs, tables, header and footer, styles, numbering, notes and media.
- Operations
- Pure functions, (doc, …) => doc, for every edit.
- DOCX
- importDocx and exportDocx, keeping what is not understood.
- Layout
- layoutDocument: lines, pages, and where the caret and the selection go.
- Output
- renderPdf, exportMarkdown.
- Templates and versions
- variableNames, fillVariables, compareDocs, restoreVersion.
Take it
When documents are made or changed in code: on a server, in a script, in a job.
Use it
import { importDocx, exportDocx, fillVariables, renderPdf } from '@rebodocs/core';
let doc = importDocx(bytes); // Uint8Array → Doc
doc = fillVariables(doc, { client: 'Northwind S.A.' });
const docx = exportDocx(doc); // Doc → Uint8Array
const { pdf } = renderPdf(doc, fonts, 'Receipt 1024'); // fonts: readFont() of your .ttf files@rebodocs/collab
RealtimeREADME →On npm →Several people on one document: the change format, the room server, and its browser client.
- Node (the server)
- Browser (the client)
- Node 22 (server) · ES2022 (client)
Get it
Depends on
@rebodocs/coreWhat is inside
- Changes
- Operations addressed by paragraph id, and how two at once are reconciled.
- Room server
- Rooms in memory, saved through your backend; it checks every editor has the document, and says who changed it in each session of work.
- Client
- What the editor connects with. @rebodocs/react already has it inside.
Import it from
- @rebodocs/collab/server
- createCollabServer, for a Node program of your own.
- @rebodocs/collab/storage
- Where rooms are kept: your backend, over HTTP.
- @rebodocs/collab/browser
- The client, for an editor without React.
Use it
import { createCollabServer } from '@rebodocs/collab/server';
import { backendStorage } from '@rebodocs/collab/storage';
const server = createCollabServer({
port: 7420,
storage: backendStorage({ url: 'https://api.example.com/docs', key: process.env.KEY }),
});
await server.ready;@rebodocs/mcp
MCPREADME →On npm →Tools for an AI assistant to read and edit documents, over files or over the one open in a browser.
- Node (the server)
- Browser (the editor’s side)
- Node 22 (server) · ES2022 (browser side)
Get it
Depends on
@rebodocs/core@anthropic-ai/sdkWhat is inside
- MCP server
- Its tools are the editor’s operations, and some of its own for contracts: read, find, replace, format, notes, tables, clauses, pages. Over standard input and output, or HTTP.
- Claude route
- The route of a backend that takes a chat in the page to the Claude API.
- Browser side
- What lets the tools work on the document open in the editor.
Import it from
- @rebodocs/mcp/claude
- assistantHandler and assistantRoute: the backend of the chat beside the editor.
- @rebodocs/mcp/browser
- The editor’s side; createAssistantChat is in @rebodocs/react.
Take it
To let an assistant work on documents, from a client such as Claude Desktop or inside your application.
Use it
// claude_desktop_config.json
{
"mcpServers": {
"rebodocs": {
"command": "npx",
"args": ["-y", "@rebodocs/mcp", "--root", "/path/to/documents"]
}
}
}The applications
Besides the packages, the repository has small applications that use them: each one a way of putting the editor in a product. See Demos to run.
apps/playgroundThe page every package is tried in. Its src/main.ts is the shortest example of everything wired together.
$ npm run devapps/demo@rebodocs/react as an application uses it: the whole editor, and an interface of its own on the hooks.
apps/viewerDocuments only to read: a shelf of them with their thumbnails, and each one opened in the viewer.
$ npm run viewerapps/storageDocuments in an S3 bucket: open, save, and a PDF made on the server.
apps/realtimeSeveral people on one document, through a backend with its three routes and signed tickets.
$ npm run realtimeapps/assistantClaude in a chat beside a shared document: the page runs the tools, the backend talks to the Claude API.
apps/desktopThe editor as a desktop application, with Tauri: .docx files on disk, a native menu, PDF.
$ npm run desktopapps/siteThis website.