Installation & Basic Usage
This page describes how to install Univer Bases and how to run it after installation. Bases is distributed as a Univer Office SDK product and currently uses plugin mode.
If the core concepts of Univer are unfamiliar, read Quickstart first.
Univer supports two integration modes: Preset Mode and Plugin Mode. Preset Mode precombines plugins and reduces configuration work. If you need deep customization or extensions, use Plugin Mode so that you can select and configure plugins individually.
Setting up via plugin mode
A browser Bases application typically registers the shared Univer runtime, the render engine, the UI shell, the formula engine, and the license first, then the Bases model and UI plugins.
Using package manager
Use a build tool that supports ES modules and the exports field in package.json.
Installation
Univer builds its UI with React and uses RxJS for data streams, and it can also be embedded in Vue or Angular applications. Ensure that the react, react-dom, and rxjs peer dependencies1 are installed. The Yarn command below adds them explicitly.
Keep every @univerjs/* and @univerjs-pro/* package on the same version.
pnpm add @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/ui @univerjs-pro/bases @univerjs-pro/bases-ui @univerjs-pro/engine-formula @univerjs-pro/licensenpm install @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/ui @univerjs-pro/bases @univerjs-pro/bases-ui @univerjs-pro/engine-formula @univerjs-pro/licenseyarn add @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/ui @univerjs-pro/bases @univerjs-pro/bases-ui @univerjs-pro/engine-formula @univerjs-pro/license react react-dom rxjsbun add @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/ui @univerjs-pro/bases @univerjs-pro/bases-ui @univerjs-pro/engine-formula @univerjs-pro/licenseUsage
Create the container with an explicit height before initializing Univer:
<div id="app" style="height: 600px"></div>Import the facade entries used below before calling FUniver.newAPI(univer). Load the @univerjs/design CSS first, then the @univerjs/ui CSS, and the product CSS last.
Caution
- Register
UniverLicensePluginbefore the Bases plugins. - Import shared UI CSS before product UI CSS.
- Use
UniverProFormulaEnginePluginfrom@univerjs-pro/engine-formulafor Bases, including dashboard shapes. If you combine products in oneUniverinstance, replace anyUniverFormulaEnginePluginimport and registration instead of registering both formula engines.
Import styles, locale packs, and the plugins you need:
TypeScriptimport { UniverBasesPlugin } from '@univerjs-pro/bases'import { UniverBasesUIPlugin } from '@univerjs-pro/bases-ui'import BasesUIEnUS from '@univerjs-pro/bases-ui/locale/en-US'import BasesEnUS from '@univerjs-pro/bases/locale/en-US'import { UniverProFormulaEnginePlugin } from '@univerjs-pro/engine-formula'import { UniverLicensePlugin } from '@univerjs-pro/license'import { LocaleType, mergeLocales, Univer, UniverInstanceType } from '@univerjs/core'import DesignEnUS from '@univerjs/design/locale/en-US'import { UniverRenderEnginePlugin } from '@univerjs/engine-render'import { UniverUIPlugin } from '@univerjs/ui'import UIEnUS from '@univerjs/ui/locale/en-US'import '@univerjs/design/lib/index.css'import '@univerjs/ui/lib/index.css'import '@univerjs-pro/bases-ui/lib/index.css'Import facade entries if you plan to use Facade API2:
TypeScriptimport { FUniver } from '@univerjs/core/facade'import '@univerjs-pro/bases/facade'import '@univerjs-pro/bases-ui/facade'Create a Univer instance, register the plugins, and create a Base unit:
TypeScriptconst univer = new Univer({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales( DesignEnUS, UIEnUS, BasesEnUS, BasesUIEnUS, ), },})univer.registerPlugin(UniverRenderEnginePlugin)univer.registerPlugin(UniverUIPlugin, { container: 'app' })univer.registerPlugin(UniverProFormulaEnginePlugin)univer.registerPlugin(UniverLicensePlugin, { license: process.env.CLIENT_LICENSE_TEXT,})univer.registerPlugin(UniverBasesPlugin)univer.registerPlugin(UniverBasesUIPlugin)univer.createUnit(UniverInstanceType.UNIVER_BASE, {})const univerAPI = FUniver.newAPI(univer)
Plugin configuration
UniverUIPlugin
containerstring | HTMLElementThe DOM element to mount into, or its ID.
UniverLicensePlugin
licensestringContents of the client license file.
univer.registerPlugin and univer.registerPlugins methods
univer.registerPlugin registers a plugin on a Univer instance. Call it after creating the instance.
The signature is univer.registerPlugin(Plugin, options). Plugin is the plugin to register, and options is an optional configuration object. Each plugin defines its own options.
univer.registerPlugins takes an array and registers several plugins in one call. Use it to keep plugin registration in one place.
univer.registerPlugins([ UniverRenderEnginePlugin, [UniverUIPlugin, { container: 'app' }], UniverProFormulaEnginePlugin, [UniverLicensePlugin, { license: process.env.CLIENT_LICENSE_TEXT, }], UniverBasesPlugin, UniverBasesUIPlugin,])Mobile support
The current @univerjs-pro/bases-ui package does not export a dedicated mobile UI plugin. Neither a MobileUIPlugin import nor a mobile: true option exists, so do not write one. A narrow container does not demonstrate complete touch support; test the existing UI on the target devices.
Other releases
Besides stable releases, Univer publishes alpha and beta channels. These channels allow you to try new features before their official release. New features also carry risk: these builds may contain bugs, incomplete functionality, or unstable features, so avoid them in production where possible.
Alpha / beta release
When the Univer team completes a new feature or a significant change, it may publish a pre-release to the alpha or beta channel. Install an alpha or beta build of a Univer package with these commands:
pnpm add @univerjs-pro/bases@alpha # Alpha version
pnpm add @univerjs-pro/bases@beta # Beta versionnpm install @univerjs-pro/bases@alpha # Alpha version
npm install @univerjs-pro/bases@beta # Beta versionyarn add @univerjs-pro/bases@alpha # Alpha version
yarn add @univerjs-pro/bases@beta # Beta versionbun add @univerjs-pro/bases@alpha # Alpha version
bun add @univerjs-pro/bases@beta # Beta versionIf you encounter a problem or have feedback while using an alpha or beta build, report it to the Univer team through GitHub Issues.
Next steps
Footnotes
-
peerDependenciesdeclare dependencies that the host application must provide with compatible versions. They let Univer share libraries such as React instead of bundling a separate copy. ↩ -
Facade is the application-facing API over registered plugins. Importing a Facade entry adds API methods; it does not register the feature plugin itself. ↩
How is this guide?