# Production deployment

> Zero-egress configuration, printing, accessibility, Node scaling, and non-React hosts.

## Zero-egress checklist

To run the SDK with zero outbound requests to Revise servers:

1. **Disable telemetry:** pass `telemetry={false}` on `<ReviseEditor />`.
2. **Self-host static assets:** mirror `fonts/`, `wasm/` (refresh on every SDK release—filenames are content-hashed), `katex.min.css`, `pdfjs/`, and `tree-sitter/` (`revise/full` only) from `https://revise.io` to your own origin, then call `setAssetBaseUrl("https://assets.example.com/revise")` once at startup.
3. **Delegated agent:** omit `agent` (or point `agent.baseUrl` / `agent.turnStream` at your own backend, and set `disableMetrics: true` if using a custom `baseUrl`).
4. **Server image fetching (`revise/server`):** configure `OpenOptions.images` (`ImageFetchPolicy`) if you want a custom `fetch` proxy or stricter size/host rules (by default, private/loopback/link-local IPs are blocked and downloads are capped at 20 MB).
5. **Server PDF WASM (`revise/server`):** place the krilla `.wasm` files in `public/wasm/` under the Node process working directory so `doc.export({ format: "pdf" })` loads them locally instead of fetching ~2.2 MB from `https://revise.io` on first export.

Commercial license keys (`licenseKey`) are verified offline and never sent over the network.

## Printing

Because pages render to `<canvas>`, native `window.print()` does not paginate document content. Print by exporting a PDF and handing it to the browser's PDF printer:

```ts
async function printDocument(editor: ReviseEditorHandle) {
  const blob = await editor.tools.export({ format: "pdf", mode: "final" });
  const url = URL.createObjectURL(blob);
  const frame = document.createElement("iframe");
  frame.style.display = "none";
  frame.src = url;
  document.body.appendChild(frame);
  frame.onload = () => {
    frame.contentWindow?.focus();
    frame.contentWindow?.print();
    setTimeout(() => {
      URL.revokeObjectURL(url);
      frame.remove();
    }, 60_000);
  };
}
```

## Accessibility

- **Supported:** Full keyboard editing and navigation, standard DOM controls for the ribbon/dialogs/panels, screen-reader progress announcements during PDF export, and accessible tagged PDF output (`pdfStandard: "pdf-ua-1"` via `revise/server`).
- **Limitation:** Document body text is painted to `<canvas>` and is not exposed in the DOM for screen readers. If WCAG screen-reader access to body text is required, pair the editor with an HTML/Markdown read view (`tools.export({ format: "html" })`) or tagged PDF export.

## Performance and scaling

### Browser

- Lazy-load `<ReviseEditor />` and `"revise/style.css"` on the document route ([load on demand](https://revise.io/developer/docs/editor-sdk/quickstart#load-on-demand)).
- For high-volume agent edits, offload edit staging to the bundled Web Worker via `agent.stagingWorker`:

```ts
<ReviseEditor
  agent={{
    stagingWorker: () =>
      new Worker(new URL("revise/staging-worker", import.meta.url), {
        type: "module",
      }),
  }}
/>
```

  Vite requires `worker: { format: "es" }` so the worker shares ES module chunks.
- For faster word diffs and document stats, opt into `wasmHotPaths` via `revise/full` (not CSP-safe).

### Node (`revise/server`)

- **Dispose every instance:** always wrap `ReviseDocument` usage in `try { ... } finally { doc.dispose(); }` to release Yjs and `jsdom` memory.
- **Concurrency:** operations on a single `ReviseDocument` serialize automatically. For batch document processing or PDF generation across many files, run a bounded concurrency pool or Node `worker_threads` rather than opening unbounded documents simultaneously.
- **PDF engine in Node:** install `@napi-rs/canvas` (recommended) or `canvas` so `doc.export({ format: "pdf" })` and `doc.renderPages()` use the krilla/canvas pipeline. Without a canvas package (or if the WASM writer cannot load), `export({ format: "pdf" })` falls back to the legacy writer and `pdfStandard` exports fail.

## Non-React hosts (Vue, Angular, vanilla)

`revise` is a React 18+ component. To embed it in a non-React application, mount it inside a thin `react-dom/client` wrapper and expose `ReviseEditorHandle`:

```ts mountRevise.ts
import React from "react";
import { createRoot } from "react-dom/client";
import ReviseEditor, {
  type ReviseEditorHandle,
  type ReviseEditorProps,
} from "revise";
import "revise/style.css";

export function mountReviseEditor(
  container: HTMLElement,
  props: ReviseEditorProps,
): { ready: Promise<ReviseEditorHandle>; unmount: () => void } {
  const root = createRoot(container);
  let resolveReady!: (handle: ReviseEditorHandle) => void;
  const ready = new Promise<ReviseEditorHandle>((r) => (resolveReady = r));

  root.render(
    React.createElement(ReviseEditor, {
      ...props,
      onReady: (handle) => {
        resolveReady(handle);
        props.onReady?.(handle);
      },
    }),
  );

  return { ready, unmount: () => root.unmount() };
}
```
