Installation & Basic Usage
This page describes how to install Univer Slides and render an editor on the page. The examples use the Web SDK Slides packages. Univer does not provide a Slides preset yet, so the application is assembled in plugin mode.
If you are unfamiliar with Univer's core concepts, read Quickstart first.
Univer provides two integration modes: Preset Mode and Plugin Mode. Preset Mode supplies preconfigured plugin bundles, which removes most of the assembly work. Applications that need deep customization or extensions use Plugin Mode, in which each plugin is selected and configured individually.
Setting up via plugin mode
Univer distributes Slides as a set of plugins. A browser editor typically registers the shared Univer runtime, the license plugin, the Docs and Drawing dependencies, and then the Slides model and UI plugins.
Using package manager
The build tool must support ES Modules and the exports field in package.json.
Installation
Univer uses React for its UI and RxJS for data streams, and it can also be embedded in Vue or Angular applications. The react, react-dom, and rxjs peer dependencies1 must be installed; the Yarn command below includes them explicitly.
All @univerjs/* and @univerjs-pro/* packages must stay on the same version.
pnpm add @univerjs/core @univerjs/design @univerjs/docs @univerjs/docs-ui @univerjs/drawing @univerjs/engine-render @univerjs/ui @univerjs-pro/license @univerjs-pro/slides @univerjs-pro/slides-uinpm install @univerjs/core @univerjs/design @univerjs/docs @univerjs/docs-ui @univerjs/drawing @univerjs/engine-render @univerjs/ui @univerjs-pro/license @univerjs-pro/slides @univerjs-pro/slides-uiyarn add @univerjs/core @univerjs/design @univerjs/docs @univerjs/docs-ui @univerjs/drawing @univerjs/engine-render @univerjs/ui @univerjs-pro/license @univerjs-pro/slides @univerjs-pro/slides-ui react react-dom rxjsbun add @univerjs/core @univerjs/design @univerjs/docs @univerjs/docs-ui @univerjs/drawing @univerjs/engine-render @univerjs/ui @univerjs-pro/license @univerjs-pro/slides @univerjs-pro/slides-uiUsage
Create the container and give it an explicit height before initializing Univer:
<div id="app" style="height: 600px"></div>Import the facade entries used in the following steps before calling FUniver.newAPI(univer). Import the @univerjs/design CSS first, then the @univerjs/ui CSS, and the product CSS last.
Caution
- Register
UniverLicensePluginbefore any Slides plugin. - Import the shared UI CSS before the product UI CSS.
- Add optional packages such as print, tables, charts, and import/export only when the product requires them.
UniverSlidesUIPluginloadsUniverProFormulaEnginePluginon its own for shapes. If the sameUniverinstance also registersUniverFormulaEnginePlugin, install@univerjs-pro/engine-formulaand replace the import and registration of that engine withUniverProFormulaEnginePluginin the initialization code. Do not register both formula engines.
Import the stylesheets, locale packs, and required plugins:
TypeScriptimport { UniverLicensePlugin } from '@univerjs-pro/license'import { UniverSlidesPlugin } from '@univerjs-pro/slides'import { UniverSlidesUIPlugin } from '@univerjs-pro/slides-ui'import SlidesUIEnUS from '@univerjs-pro/slides-ui/locale/en-US'import SlidesEnUS from '@univerjs-pro/slides/locale/en-US'import { LocaleType, mergeLocales, Univer, UniverInstanceType } from '@univerjs/core'import DesignEnUS from '@univerjs/design/locale/en-US'import { UniverDocsPlugin } from '@univerjs/docs'import { UniverDocsUIPlugin } from '@univerjs/docs-ui'import DocsUIEnUS from '@univerjs/docs-ui/locale/en-US'import { UniverDrawingPlugin } from '@univerjs/drawing'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/docs-ui/lib/index.css'import '@univerjs-pro/slides-ui/lib/index.css'To use the Facade API2, import the facade entries as well:
TypeScriptimport { FUniver } from '@univerjs/core/facade'import '@univerjs-pro/slides/facade'Create a Univer instance, register the plugins, and create a Slides unit:
TypeScriptconst univer = new Univer({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales( DesignEnUS, UIEnUS, DocsUIEnUS, SlidesEnUS, SlidesUIEnUS, ), },})univer.registerPlugin(UniverRenderEnginePlugin)univer.registerPlugin(UniverUIPlugin, { container: 'app',})univer.registerPlugin(UniverDocsPlugin)univer.registerPlugin(UniverDocsUIPlugin)univer.registerPlugin(UniverDrawingPlugin)univer.registerPlugin(UniverLicensePlugin, { license: process.env.CLIENT_LICENSE_TEXT,})univer.registerPlugin(UniverSlidesPlugin)univer.registerPlugin(UniverSlidesUIPlugin)univer.createUnit(UniverInstanceType.UNIVER_SLIDE, {})const univerAPI = FUniver.newAPI(univer)
The univerAPI object that FUniver.newAPI(univer) returns is Univer's Facade API. The application uses it to create presentations and to call Slides APIs.
Plugin configuration
UniverUIPlugin
containerstring | HTMLElementMount element or its DOM ID.
UniverLicensePlugin
licensestringClient license file contents.
univer.registerPlugin and univer.registerPlugins methods
Call univer.registerPlugin after creating the Univer instance to register a single plugin.
The signature is univer.registerPlugin(Plugin, options). Plugin is the plugin class, and options holds the configuration of that plugin.
univer.registerPlugins accepts an array and registers several plugins in one call. This form is convenient when the plugin list should be maintained in one place.
univer.registerPlugins([ UniverRenderEnginePlugin, [UniverUIPlugin, { container: 'app', }], UniverDocsPlugin, UniverDocsUIPlugin, UniverDrawingPlugin, [UniverLicensePlugin, { license: process.env.CLIENT_LICENSE_TEXT, }], UniverSlidesPlugin, UniverSlidesUIPlugin,])Optional feature packages
Install a feature package when the editor needs the corresponding capability:
pnpm add @univerjs-pro/slides-printpnpm add @univerjs-pro/slides-table @univerjs-pro/slides-table-uipnpm add @univerjs-pro/chart-ui @univerjs-pro/slides-chart @univerjs-pro/slides-chart-uipnpm add @univerjs-pro/slides-exchange-clientRegistration examples are given in Printing, Table, Charts, and Import and export.
Lazy-load optional plugins
Plugin mode also allows a feature plugin to be loaded only when the product needs it:
univer.createUnit(UniverInstanceType.UNIVER_SLIDE, {})import('@univerjs-pro/slides-chart').then(({ UniverSlidesChartPlugin }) => { univer.registerPlugin(UniverSlidesChartPlugin)})Server-side usage
In Node.js, register the model plugins and omit the browser UI plugins:
univer.registerPlugin(UniverSlidesPlugin)The model plugin performs headless snapshot processing. Exposing collaboration or file-conversion APIs requires the corresponding Server SDK modules. Registering this plugin alone does not create those services.
Mobile support
These examples require SDK packages that export the mobile plugins listed below. All @univerjs/* and @univerjs-pro/* dependencies must remain on the same version.
1.0.0-rc.0 does not export UniverSlidesMobileUIPlugin. Choose a build that includes this mobile entry before following the example.
Touch controls in Univer Slides require mobile UI plugins.3 Decide the UI mode before creating the editor.
In the plugin-mode example above, replace the UI imports and registrations with those below before createUnit(). Do not append them to a desktop editor that has already been initialized. Keep the model plugins, engines, locale files, CSS, and Facade imports. Desktop and mobile classes are named exports from the same package entry.
UniverMobileUIPlugin
containerstring | HTMLElementMount element or its DOM ID.disableAutoFocustrueDefault:truePrevents the editor from taking focus at startup.
import { UniverSlidesMobileUIPlugin } from '@univerjs-pro/slides-ui'import { UniverDocsMobileUIPlugin } from '@univerjs/docs-ui'import { UniverMobileUIPlugin } from '@univerjs/ui'univer.registerPlugin(UniverMobileUIPlugin, { container: 'app' })univer.registerPlugin(UniverDocsMobileUIPlugin)univer.registerPlugin(UniverSlidesMobileUIPlugin)Plugin mapping
Register only the features in use, and keep their model plugins and required dependencies. A mobile UI export does not mean that desktop and mobile offer the same controls. Pro features still require the appropriate license. Features with a backend require application-side integration with the Univer Server SDK.
| Package | Desktop registration | Mobile registration |
|---|---|---|
@univerjs/ui | UniverUIPlugin | UniverMobileUIPlugin |
@univerjs/docs-ui | UniverDocsUIPlugin | UniverDocsMobileUIPlugin |
@univerjs-pro/slides-ui | UniverSlidesUIPlugin | UniverSlidesMobileUIPlugin |
@univerjs/drawing-ui | UniverDrawingUIPlugin | UniverDrawingMobileUIPlugin |
@univerjs/thread-comment-ui | UniverThreadCommentUIPlugin | UniverThreadCommentMobileUIPlugin |
@univerjs-pro/shape-editor-ui | UniverShapeEditorUIPlugin | UniverShapeEditorMobileUIPlugin |
@univerjs-pro/chart-ui | UniverChartUIPlugin | UniverChartMobileUIPlugin |
@univerjs-pro/exchange-client | UniverExchangeClientPlugin | UniverExchangeClientMobileUIPlugin |
@univerjs-pro/slides-chart-ui | UniverSlidesChartUIPlugin | UniverSlidesChartMobileUIPlugin |
@univerjs-pro/slides-print | UniverSlidesPrintPlugin | UniverSlidesPrintMobilePlugin |
@univerjs-pro/slides-table-ui | UniverSlidesTableUIPlugin | UniverSlidesTableMobileUIPlugin |
@univerjs-pro/slides-thread-comment-ui | UniverSlidesThreadCommentUIPlugin | UniverSlidesThreadCommentMobileUIPlugin |
Container and touch interaction
The container needs an explicit height, and the page viewport must be configured. 100dvh follows the dynamic viewport height. Test scrolling, pinch zoom, text selection, clipboard access, and the on-screen keyboard in the targeted mobile browsers. Resizing a desktop editor does not switch it to mobile plugins.
UniverMobileUIPlugin defaults to disableAutoFocus: true, so the editor does not take focus automatically during initialization.
<meta name="viewport" content="width=device-width, initial-scale=1" /><div id="app" style="height: 100dvh"></div>Other releases
Univer publishes alpha / beta channels alongside its stable releases. They make new features available before their official release, at the cost of higher risk. These versions may contain bugs, incomplete functionality, or unstable features, so they should be avoided in production where possible.
Alpha / beta release
When the Univer team completes a new feature or a significant change, it may pre-release the work to the alpha or beta channel. Install the alpha / beta version of a Univer package as follows:
pnpm add @univerjs-pro/slides@alpha # Alpha version
pnpm add @univerjs-pro/slides@beta # Beta versionnpm install @univerjs-pro/slides@alpha # Alpha version
npm install @univerjs-pro/slides@beta # Beta versionyarn add @univerjs-pro/slides@alpha # Alpha version
yarn add @univerjs-pro/slides@beta # Beta versionbun add @univerjs-pro/slides@alpha # Alpha version
bun add @univerjs-pro/slides@beta # Beta versionReport problems and feedback on an alpha / beta version to the Univer team through GitHub Issues.
Next steps
- Learn how to operate Slides through the Facade API.
- License configuration
- Server SDK integration
- Add feature plugins from the Features section.
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. ↩
-
A mobile UI plugin selects touch controls and mobile services during initialization. It does not automatically detect the device or switch an existing instance when the window is resized. To change modes, preserve the document state, dispose of the old instance and initialize the chosen plugin set. ↩
How is this guide?