Univer Bases API

Learn how to use Facade API in a Univer Bases application.

Facade API provides an application-facing layer over the Bases model. Use it for common operations such as creating bases, tables, fields, records, views, filters, sorts, groups, selections, and UI navigation.

Caution

Base model mutations are synchronous. UI activation methods return promises and should be awaited.

Enable facade entries

Import the facade entry for every Bases capability used by your application:

TypeScript
import { FUniver } from '@univerjs/core/facade'import '@univerjs-pro/bases/facade'import '@univerjs-pro/bases-ui/facade'

Create the API object after the Univer instance and required plugins are registered:

TypeScript
const univerAPI = FUniver.newAPI(univer)

Create and read a base

Use createBase to create a Base unit through the facade layer. In lower-level setup code, create the unit with univer.createUnit(UniverInstanceType.UNIVER_BASE, snapshot).

TypeScript
const base = univerAPI.createBase({  id: 'base-demo',  name: 'Base Demo',})const activeBase = univerAPI.getActiveBase()const sameBase = univerAPI.getBase(base.getId())

Create a table

TypeScript
const table = base.insertTable('Tasks', { primaryFieldName: 'Title' })const status = table.addField('Status', univerAPI.Enum.BaseFieldType.Text)

Work with records

TypeScript
const record = table.addRecord({  Title: 'Write docs',  Status: 'In progress',}, univerAPI.Enum.BaseFieldKeyEnum.Name)record.setValue(status.getId(), 'Done')

Work with UI state

@univerjs-pro/bases-ui/facade adds UI APIs for table/view activation, selection, scrolling, editing, and panels.

TypeScript
const baseUI = univerAPI.getBaseUI()const view = table.getViews()[0]if (!view) throw new Error('No table view')await baseUI.activateTable(table.getId())await baseUI.activateView(view.getId())baseUI.setSelection({  type: 'grid-record',  tableId: table.getId(),  viewId: view.getId(),  recordId: record.getId(),})

Reference

How is this guide?

© 2026 DreamNum Co., Ltd.