Installation & Basic Usage
This chapter introduces the installation and basic usage of Univer Slides. This guide uses the Web SDK Slides packages. There is currently no Slides preset, so create the application in plugin mode.
If you are not familiar with Univer's core concepts, read Quickstart first.
Univer supports two integration modes: Preset Mode and Plugin Mode. Preset Mode simplifies setup with preconfigured plugin bundles. If you need deep customization or extensions, we recommend Plugin Mode so you can combine and configure plugins individually.
Setting Up via Plugin Mode
Univer exposes Slides as a set of plugins. A browser editor usually registers the shared Univer runtime, the license plugin, Docs and Drawing dependencies, and then the Slides model and UI plugins.
Using Package Manager
Use a build tool that supports ES Modules and the exports field in package.json.
Installation
Univer uses React for its UI and RxJS for data streams; it can also be embedded in Vue or Angular applications. Check that react, react-dom, and rxjs peer dependencies1 are installed. The Yarn command below includes them explicitly.
Keep all @univerjs/* and @univerjs-pro/* packages 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 before initializing Univer and give it an explicit height:
<div id="app" style="height: 600px"></div>Import the facade entries used below before calling FUniver.newAPI(univer). Import @univerjs/design CSS first, then @univerjs/ui CSS, and finally product CSS.
Caution
- Register
UniverLicensePluginbefore registering Slides plugins. - Import the shared UI CSS before product UI CSS.
- Optional feature packages such as print, tables, charts, and import/export should be added only when the product needs them.
UniverSlidesUIPluginautomatically loadsUniverProFormulaEnginePluginfor shapes. If the sameUniverinstance also registersUniverFormulaEnginePlugin, install@univerjs-pro/engine-formulaand replace that engine's import and registration withUniverProFormulaEnginePluginin your initialization code. Do not register both formula engines.
Import styles, locale packs, and the 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'Import facade entries if you want to use Facade API2:
TypeScriptimport { FUniver } from '@univerjs/core/facade'import '@univerjs-pro/slides/facade'Create a Univer instance, register 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 returned by FUniver.newAPI(univer) is Univer's Facade API. Use it to create presentations and call Slides APIs.
univer.registerPlugin and univer.registerPlugins Methods
univer.registerPlugin method is used to register a plugin to the Univer instance. You can call this method after creating the Univer instance to register plugins.
You can register a plugin using the univer.registerPlugin(Plugin, options) method, where Plugin is the plugin to be registered, and options are optional configuration items, as each plugin may have different configuration items.
Use univer.registerPlugins to pass an array and register multiple plugins at once. This is useful for scenarios where you need to manage plugins centrally.
univer.registerPlugins([ UniverRenderEnginePlugin, [UniverUIPlugin, { container: 'app', }], UniverDocsPlugin, UniverDocsUIPlugin, UniverDrawingPlugin, [UniverLicensePlugin, { license: process.env.CLIENT_LICENSE_TEXT, }], UniverSlidesPlugin, UniverSlidesUIPlugin,])Optional feature packages
Add feature packages 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-clientFor feature registration examples, see Printing, Table, Charts, and Import and export.
Lazy-load optional plugins
Plugin mode lets you delay feature plugins until the product actually needs them:
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 skip browser UI plugins:
univer.registerPlugin(UniverSlidesPlugin)The model plugin supports headless snapshot processing. To expose collaboration or file-conversion APIs, integrate 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. Keep all @univerjs/* and @univerjs-pro/* dependencies on the same version.
1.0.0-rc.0 does not export UniverSlidesMobileUIPlugin. Use a build that includes this mobile entry before following the example.
Use mobile UI plugins for touch-oriented controls in Univer Slides.3 Choose the UI mode before creating the editor.
In the plugin-mode example above, replace the following UI imports and registrations before createUnit(); do not append them to an initialized desktop editor. Keep model plugins, engines, locale files, CSS and Facade imports. Desktop and mobile classes are named exports from the same package entry.
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
Only register features you use. Keep their model plugins and required dependencies; a mobile UI export does not mean the desktop and mobile interfaces have identical controls. Pro features still require the appropriate license. Features that need a backend require application-side integration with 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
Give the container an explicit height and configure the page viewport. 100dvh follows the dynamic viewport height. Check scrolling, pinch zoom, text selection, clipboard access and the on-screen keyboard in your target mobile browsers. Resizing a desktop editor alone does not select mobile plugins.
UniverMobileUIPlugin defaults to disableAutoFocus: true, preventing the editor from taking focus automatically during initialization.
<meta name="viewport" content="width=device-width, initial-scale=1" /><div id="app" style="height: 100dvh"></div>Other Releases
In addition to stable releases, Univer offers alpha / beta channels. These versions allow you to get early access to the newest features that have not been officially released yet. However, keep in mind that more features also mean more risks. These versions may contain bugs, incomplete functionality, or unstable features. Please avoid using these versions in production environments whenever possible.
Alpha / Beta Release
When the Univer development team completes a new feature or significant change, they may pre-release it to the alpha or beta channel. You can install the alpha / beta version of a Univer package using the following command:
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 versionIf you encounter any issues or have any feedback while using alpha / beta versions, please report them to the Univer development team through GitHub Issues.
We welcome your feedback on these early releases.
Next Steps
- Learn how to use 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?