Revise Editor SDK menu

Server-side work

Convert, edit, and export documents in Node with revise/server.

revise/server is the ESM-only Node 20+ entry point bundled in revise. It does not import React, and the browser editor never imports revise/server.

Terminal
npm i revise

Y.Doc state is interchangeable between the browser editor and revise/server, and both use the same converters, tool schemas, and { ok, value | error } result envelope:

TypeScript
import { ReviseDocument } from "revise/server";
import type * as Y from "yjs";

async function reviewRoom(room: Y.Doc): Promise<Uint8Array> {
  const doc = await ReviseDocument.fromYDoc(room, { author: "Review bot" });
  try {
    const [hit] = doc.grep("Delaware");
    if (hit) {
      await doc.tools.call("replace", {
        id: hit.id,
        replacements: [{ find: "Delaware", replace: "New York" }],
      });
    }
    const { bytes } = await doc.export({ format: "docx" });
    return bytes;
  } finally {
    doc.dispose(); // leaves room alive
  }
}

Upgrade from 2.x#

4.x replaces the 2.x standalone functions with ReviseDocument (legacy names remain exported and throw with migration messages; see the 2.3 reference):

2.x4.x
createServerDocumentSession(ydoc)ReviseDocument.fromYDoc(ydoc), then doc.tools
parseDocument, documentToDocx, fileToYDocReviseDocument.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, decodeYDocY.encodeStateAsUpdate(doc.ydoc); ReviseDocument.restore(update)

Porting notes:

  • ReviseDocument methods are async.
  • doc.tools.call() (typed) and doc.tools.run() (untyped) return ReviseToolResult instead of throwing.
  • doc.export() returns { bytes, fidelity, warnings, … }.
  • doc.snapshot() uses Revise's own storage format; use Y.encodeStateAsUpdate(doc.ydoc) for Yjs transports.

License#

revise/server is governed by the SDK license, including commercial-use requirements for server-only deployments.