Integrate in Angular

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

Before adding Univer to an Angular project, read installation and basic usage and become familiar with Angular components and lifecycle hooks.

Integration steps

  1. Initialize Univer in ngAfterViewInit.
  2. Dispose of it in ngOnDestroy.

Preset configuration

UniverDocsCorePreset

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

Example

TypeScript
import type { AfterViewInit, ElementRef, OnDestroy } from '@angular/core'import type { Univer } from '@univerjs/presets'import { Component, ViewChild } from '@angular/core'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'@Component({  selector: 'app-univer',  standalone: true,  template: '<div #container style="height: 600px"></div>',})export class UniverComponent implements AfterViewInit, OnDestroy {  @ViewChild('container') container!: ElementRef<HTMLDivElement>  private univer?: Univer  ngAfterViewInit() {    const { univer, univerAPI } = createUniver({      locale: LocaleType.EN_US,      locales: {        [LocaleType.EN_US]: mergeLocales(          UniverPresetDocsCoreenUS,        ),      },      presets: [        UniverDocsCorePreset({          container: this.container.nativeElement,        }),      ],    })    this.univer = univer    univerAPI.createDocument({})  }  ngOnDestroy() {    this.univer?.dispose()  }}

How is this guide?

© 2026 DreamNum Co., Ltd.