# @univerjs/rpc

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/rpc](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/rpc)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/rpc.md](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs/rpc.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [packages/plugins/univerjs/rpc.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/packages/plugins/univerjs/rpc.mdx)

---

Browser RPC layer for Univer main-thread and worker communication.

```typescript
// [!code word:UniverRPCMainThreadPlugin]
// [!code word:IUniverRPCMainThreadConfig]
import type { IUniverRPCMainThreadConfig } from '@univerjs/rpc'
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc'

const config: IUniverRPCMainThreadConfig = {
  workerURL: new URL('./worker.js', import.meta.url),
}
univer.registerPlugin(UniverRPCMainThreadPlugin, config)
```

`workerURL` is required when the main-thread plugin starts. Build the following worker entry separately and point `workerURL` to its output.

```typescript
// [!code word:UniverRPCWorkerThreadPlugin]
import { UniverRPCWorkerThreadPlugin } from '@univerjs/rpc'

univer.registerPlugin(UniverRPCWorkerThreadPlugin)
```

## IUniverRPCMainThreadConfig

```ts
export interface IUniverRPCMainThreadConfig {
  workerURL?: string | URL | Worker
}
```

## IUniverRPCWorkerThreadConfig

```ts
export interface IUniverRPCWorkerThreadConfig {
}
```
