Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

1.9 KB
Raw Blame

@univerjs/rpc-node

npm version license downloads

@univerjs/rpc-node provides the Node.js counterpart for Univer RPC scenarios, allowing main-thread and worker-side plugins to communicate outside the browser.

Package Overview

Package UMD global CSS Locales Facade entry Worker entry
@univerjs/rpc-node UniverRpcNode No No No Yes

Installation

pnpm add @univerjs/rpc-node
# or
npm install @univerjs/rpc-node

Usage

Start with the integration setup for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.

import { fileURLToPath } from 'node:url';
import { UniverRPCNodeMainPlugin } from '@univerjs/rpc-node';

const workerSrc = fileURLToPath(new URL('./worker.js', import.meta.url));
univer.registerPlugin(UniverRPCNodeMainPlugin, { workerSrc });

Main-thread plugin classes:

  • UniverRPCNodeMainPlugin

Worker usage

On the main thread, import UniverRPCNodeMainPlugin from @univerjs/rpc-node. Set workerSrc to the worker module path.

In the worker entry, import UniverRPCNodeWorkerPlugin from @univerjs/rpc-node/worker:

import { UniverRPCNodeWorkerPlugin } from '@univerjs/rpc-node/worker';

univer.registerPlugin(UniverRPCNodeWorkerPlugin);

Resources