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.
npm i reviseY.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:
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
}
}Open, read, edit, review, and export documents.
Seed, edit, and export live Yjs rooms.
Coordinate server and browser peers in one room.
Run agent tools headlessly in Node.
Template filling, table updates, version comparison, and conversion.
Zero-egress setup, WASM caching, and Node concurrency.
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.x | 4.x |
|---|---|
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.encodeStateAsUpdate(doc.ydoc); ReviseDocument.restore(update) |
Porting notes:
ReviseDocumentmethods are async.doc.tools.call()(typed) anddoc.tools.run()(untyped) returnReviseToolResultinstead of throwing.doc.export()returns{ bytes, fidelity, warnings, … }.doc.snapshot()uses Revise's own storage format; useY.encodeStateAsUpdate(doc.ydoc)for Yjs transports.
License#
revise/server is governed by the SDK license, including commercial-use requirements for server-only deployments.