@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 | UMD global | CSS | Locales | Facade entry | Worker entry |
|---|---|---|---|---|---|
@univerjs/rpc-node |
UniverRpcNode |
No | No | No | Yes |
pnpm add @univerjs/rpc-node
# or
npm install @univerjs/rpc-nodeStart 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
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);