Migration
This guide helps you migrate your plugins to newer versions of the ONLYOFFICE Apps Plugin SDK.
Updating a plugin to SDK 3.0.0
SDK 3.0.0 is compatible with ONLYOFFICE Apps 4.0.0 and later. Plugins built with SDK 3.0.0 have minDocSpaceVersion: "4.0.0" set automatically in config.json by the build process. On older versions, plugins install but are flagged as incompatible and do not function.
The 3.0.0 template builds with Vite 8 and @vitejs/plugin-react 6, which require Node.js ^20.19.0 || >=22.12.0. On older Node.js versions, such as Node.js 18, vite build does not run. Check your version with node -v before migrating.
Migrating from SDK 2.x
For plugins created with an SDK 2.x template:
-
Update the SDK to version 3.0.0:
npm install @onlyoffice/docspace-plugin-sdk@^3.0.0noteThe 2.x version of
build-docspace-plugindoes not copyruntimeinto config.json. Withoutruntime: "module", the portal loads plugin.js as a regular script, and a plugin that usesexport defaultwill not register. -
Update tsconfig.json to use the 3.0 template configuration:
Replace the contents of tsconfig.json with:
{"compilerOptions": {"target": "ES2017","module": "ESNext","lib": ["ES2017", "DOM"],"jsx": "react-jsx","strict": true,"isolatedModules": true,"esModuleInterop": true,"resolveJsonModule": true,"allowSyntheticDefaultImports": true,"moduleResolution": "bundler","skipLibCheck": true},"exclude": ["node_modules", "dist"],"include": ["src/**/*"]}noteThe 2.x template uses
module: "CommonJS"andmoduleResolution: "node", and does not setjsx. With that configuration, TypeScript and IDEs cannot resolve@onlyoffice/docspace-plugin-sdk/reactor accept JSX. -
Remove Webpack:
-
Delete the old configuration files:
rm webpack.config.js custom.d.ts -
Uninstall the Webpack packages from the 2.x template:
npm uninstall webpack webpack-cli ts-loader css-loader mini-css-extract-plugin css-minimizer-webpack-plugin
notecustom.d.ts declared the types for CSS Modules and image imports. If your plugin uses them, add src/vite-env.d.ts instead, as described in Plugin structure.
-
-
Replace Webpack with Vite:
- Create a vite.config.ts file in the plugin root folder
- Install Vite as a dev dependency:
npm i -D vite
noteIf your plugin uses React, install
npm i -D @vitejs/plugin-reactand include it in thepluginsarray. If your plugin does not use React, omit thereact()plugin or use an emptyplugins: []array.import { defineConfig } from "vite";import react from "@vitejs/plugin-react"; // Only needed if your plugin uses Reactimport { fileURLToPath } from "url";const __dirname = fileURLToPath(new URL(".", import.meta.url));export default defineConfig({plugins: [react()], // Remove react() if your plugin does not use Reactdefine: {"process.env.NODE_ENV": JSON.stringify("production"),"process.env": "{}",},build: {lib: {entry: `${__dirname}src/index.ts`,formats: ["es"],fileName: () => "plugin.js",},rolldownOptions: {// Kept out of the bundle: ONLYOFFICE Apps supplies its own copies at load// time and rewrites these specifiers to them. A second React arrives with// its own contexts, so every SDK hook throws. The SDK root stays bundled// like any other dependency: string enums and types, no module state.//// The UI kit pattern matches both the package root and subpaths, but// the portal ONLY substitutes @onlyoffice/apps-ui-kit itself. Always// import from the root: `import { Button } from "@onlyoffice/apps-ui-kit"`.external: ["react","react-dom","react/jsx-runtime","@onlyoffice/docspace-plugin-sdk/react",/^@onlyoffice\/apps-ui-kit(\/.*)?$/,],output: {codeSplitting: false,assetFileNames: (assetInfo: { name?: string }) =>assetInfo.name?.endsWith(".css")? "plugin.css": (assetInfo.name ?? "asset"),},},},}); -
Change the build script in package.json:
{"scripts": {"build": "vite build && npx build-docspace-plugin",...},...} -
Update package.json and src/index.ts:
- Add
"type": "module"to package.json (required for ES modules) - Add
"runtime": "module"to package.json - Add Vite version to
devDependencies:"vite": "^8.3.0" - If your plugin uses React, add
"@vitejs/plugin-react": "^6.0.0","@types/react": "^19.0.0", and"@types/react-dom": "^19.0.0"todevDependencies, and"react": "^19.0.0","react-dom": "^19.0.0"todependencies, as in the 3.0.0 template - Update TypeScript in
devDependenciesto"typescript": "^5.6.0" - Export the plugin instance as the default export
- Remove the window.Plugins registration from src/index.ts
- Add
-
(Optional) Replace deprecated APIs:
The following deprecated APIs still work but should be replaced:
bodyin IInfoPanelItem and IArticleButtonItem — replace withcomponentcontentin IMediaViewer — replace withcomponentsettingsin ISettings — replace withcomponentdialogBodyanddialogFooterin IModalDialog — replace withdialogBodyComponentonLoadon those items and components — move the work into auseEffectinside the React component- the UsersType enum in
usersTypes— replace with UserRole. The member names differ where the portal renamed the type:docSpaceAdminisfullAdmin,collaboratorisuser, and the olduser(the guest type) isguest
Migrating from SDK 1.1.1
For plugins created with the old template (SDK 1.1.1):
-
Update the SDK to version 3.0.0 as described in step 1 above.
-
The build process is now handled by
npx build-docspace-plugin, so the scripts/createZip.js file and its reference in package.json can be safely removed:rm -rf scripts/createZip.js -
Follow the same migration steps as SDK 2.x above (steps 2-7).