Installation
Install from npm. Free for evaluation, personal projects, and education.
The SDK is the revise package on the public npm registry.
Installing it requires no account or token.
npm i revisepnpm add reviseyarn add revise yjs y-protocolsnpm and pnpm install the peer dependencies (React, yjs, y-protocols)
automatically. On Yarn, list them: yarn add revise yjs y-protocols.
revise/server and its runtime are included in revise.
revise is free for evaluation, personal projects, and education. Production
use by businesses, nonprofits, and government requires a
commercial license. Building and prototyping are free.
Entry points#
| Import | What it is |
|---|---|
revise | The React editor. import ReviseEditor from "revise". |
revise/full | The same editor plus Tree-sitter syntax highlighting and the WASM hot paths. Not CSP-safe; opt in if needed. |
revise/style.css | The stylesheet. Import it once. |
revise/version | Build identity (REVISE_SDK_VERSION, REVISE_SDK_BUILD) alone. No runtime weight. |
revise/server | Server-side work in Node, bundled with the SDK and covered by its license. |
Peer dependencies#
React 18 or newer, yjs, and y-protocols are required peers. The SDK does
not bundle its own copies. Every editor session uses Yjs, with or without a
collaboration provider.
| Package | Needed for |
|---|---|
yjs, y-protocols | All editor sessions; collaboration also passes host-created Yjs objects, so your bundler must resolve exactly one copy |
The editor never loads revise/server. Server code imports revise/server
and doesn't load React. It
needs Node 20 or newer and brings its own DOM implementation, so there is no
jsdom to install.
Bundle size#
The editor is a word processor, with DOCX, layout, and PDF export, and its main chunk is about 2.7 MB minified (about 800 KB gzipped). Load it where a document opens rather than in your entry bundle; see load on demand. Converters, PDF export, math, and locales load separately, when first used.
Vite warns about any chunk over 500 kB. For the editor that warning is expected. Raise the limit if you want a clean build:
export default defineConfig({
build: { chunkSizeWarningLimit: 3000 },
});Versioning#
The package follows semantic versioning. Pin what you ship:
{
"dependencies": {
"revise": "4.3.0"
}
}Use an exact version, not a range. The package ships a CHANGELOG.md. Read
it before changing versions. Breaking changes to the component props or the
handle controllers ship only in major versions.
Upgrade from an earlier version#
Earlier versions of the editor were installed as @reviseio/editor. Change the
dependency to revise and update the imports. The component, its props, and
the handle are unchanged.
npm uninstall @reviseio/editor
npm i revise@4.3.0pnpm remove @reviseio/editor
pnpm add revise@4.3.0yarn remove @reviseio/editor
yarn add revise@4.3.0| Earlier import | Now |
|---|---|
@reviseio/editor, revise/editor | revise |
@reviseio/editor/full, revise/editor/full | revise/full |
@reviseio/editor/version | revise/version |
@reviseio/editor/style.css | revise/style.css |
@reviseio/editor/server | revise/server |
If your bundler config names the package (for example Vite's
optimizeDeps.exclude), rename it there too. Docs for 3.1 stay available from
the version menu.
Server-side code#
Server-side work uses revise/server, included in revise.
The SDK license covers this API, including its commercial-use requirements. Code written against an earlier server entry
point maps like this:
| Earlier | revise/server |
|---|---|
createServerDocumentSession(ydoc) | ReviseDocument.fromYDoc(ydoc), then doc.tools |
parseDocument, documentToDocx, fileToYDoc | ReviseDocument.open(file), doc.export({ format: "docx" }), doc.ydoc |
exportDocument(room, { mode }), ydocToDocx(room) | ReviseDocument.fromYDoc(room), then doc.export({ format, mode }) |
seedYDocFromFile(room, bytes, filename) | seedYDoc(room, { bytes, filename }) |
encodeYDoc, decodeYDoc | Y.js itself: Y.encodeStateAsUpdate(doc.ydoc); ReviseDocument.restore(update) opens a bare update |
Documents move between the two unchanged: a Y.Doc the editor edits is a Y.Doc
revise/server opens, and the reverse. When porting, await its methods,
check result.ok on tool calls instead of catching, and write the .bytes of
doc.export(). doc.snapshot() is its own storage format; anything that
speaks Y.js takes Y.encodeStateAsUpdate(doc.ydoc).
Report a problem#
Include the SDK version and build. Both are exported, so your error reporting can attach them:
import { REVISE_SDK_VERSION, REVISE_SDK_BUILD } from "revise/version";
// "4.4.0", "f7dc7173"npm bugs revise opens the support route.
Assets#
The SDK loads some static assets on demand instead of bundling them:
- PDF export fonts, including the CJK and world-script faces
- the PDF writer (WebAssembly)
- math fonts and stylesheet
- the PDF reader's worker
- Tree-sitter grammars (
revise/fullonly)
By default they load from https://revise.io. A strict Content Security Policy
must allow that origin in connect-src, font-src, style-src, and
worker-src.
To serve them yourself, mirror these paths from https://revise.io to your
origin with the same layout:
fonts/wasm/(refresh it with every release: the PDF writer's file name changes with its contents)katex.min.csspdfjs/tree-sitter/(only forrevise/full)
Then set the base URL once at startup:
import { setAssetBaseUrl } from "revise";
setAssetBaseUrl("https://assets.example.com/revise");Troubleshooting#
ERESOLVE peer dependency errors
The package requires React 18 or newer. Installing on React 17 or earlier fails.
Unexpected content type in insert operation
Two copies of Yjs are loaded. Make your bundler resolve a single yjs, for
example with a resolve.dedupe entry in Vite.