Integrate in Vue

To use Vue components as custom components, see custom components.

Before adding Univer to a Vue project, read installation and basic usage and make sure you understand how Vue components and lifecycle hooks work.

Vue 3.x

Notes before integration

  • Do not wrap the Univer and FUniver instances in a proxy. Proxies can cause unpredictable errors and performance problems.

Integration steps

  1. Initialize Univer in onMounted.
  2. Dispose of it in onBeforeUnmount.

Preset configuration

UniverDocsCorePreset

  • container
    string | HTMLElementDefault: 'app'
    The element to mount into, or its DOM ID.

Example

Vue
<script lang="ts" setup>import type { Univer } from '@univerjs/presets'import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'import UniverPresetDocsCoreEnUS from '@univerjs/preset-docs-core/locales/en-US'import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'import { onBeforeUnmount, onMounted, ref } from 'vue'import '@univerjs/preset-docs-core/lib/index.css'const container = ref<HTMLElement | null>(null)let univerInstance: Univer | null = nullonMounted(() => {  const { univer, univerAPI } = createUniver({    locale: LocaleType.EN_US,    locales: {      [LocaleType.EN_US]: mergeLocales(        UniverPresetDocsCoreEnUS,      ),    },    presets: [      UniverDocsCorePreset({        container: container.value as HTMLElement,      }),    ],  })  univerAPI.createDocument({})  univerInstance = univer})onBeforeUnmount(() => {  univerInstance?.dispose()  univerInstance = null})</script><template>  <div ref="container" style="height: 600px" /></template>

Vue 2.x

Notes before integration

  • When you install @univerjs/presets with pnpm, you may also need to install react and react-dom separately.
  • If a "ResizeObserver loop limit exceeded" warning appears during development, it can be ignored or suppressed with the snippet below:
TypeScript
if (process.env.NODE_ENV === 'development') {  const _ResizeObserver = window.ResizeObserver  function debounce(fn, delay) {    let timer = null    return function () {      if (timer) {        clearTimeout(timer)      }      timer = setTimeout(() => {        fn.apply(this, arguments)      }, delay)    }  }  window.ResizeObserver = class ResizeObserver extends _ResizeObserver {    constructor(callback) {      callback = debounce(callback, 50)      super(callback)    }  }}

Integration steps

  1. Initialize Univer in mounted.
  2. Dispose of it in beforeDestroy.

Example

Vue
<script>import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'import UniverPresetDocsCoreEnUS from '@univerjs/preset-docs-core/locales/en-US'import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'import '@univerjs/preset-docs-core/lib/index.css'export default {  mounted() {    const { univer, univerAPI } = createUniver({      locale: LocaleType.EN_US,      locales: {        [LocaleType.EN_US]: mergeLocales(          UniverPresetDocsCoreEnUS,        ),      },      presets: [        UniverDocsCorePreset({          container: this.$refs.container,        }),      ],    })    univerAPI.createDocument({})    this.univerInstance = univer  },  beforeDestroy() {    this.univerInstance?.dispose()    this.univerInstance = null  },}</script><template>  <div ref="container" style="height: 600px" /></template>

How is this guide?

© 2026 DreamNum Co., Ltd.