Skip to main content

Coding plugin

Develop a plugin. Follow the plugin structure described here.

React components​

An item can render a React component instead of a declarative IBox tree. Pass the component through:

The component is rendered inside the ONLYOFFICE Apps application tree and reaches the portal through the hooks from @onlyoffice/docspace-plugin-sdk/react:

import {
usePluginAPI,
usePluginActions,
usePluginSettings,
useCurrentFile,
useCurrentUser,
usePluginRuntime,
} from "@onlyoffice/docspace-plugin-sdk/react";

React API Reference​

For complete React hooks and API documentation, see:

Quick Example​

import { useEffect, useState } from "react";
import { usePluginAPI } from "@onlyoffice/docspace-plugin-sdk/react";

type MyDocuments = { files: { id: number; title: string }[] };

function FileList() {
const api = usePluginAPI();
const [files, setFiles] = useState<MyDocuments["files"]>([]);

useEffect(() => {
const controller = new AbortController();
api
.get<MyDocuments>("/files/@my", { count: 20 }, { signal: controller.signal })
.then((folder) => setFiles(folder.files));
return () => controller.abort();
}, []);

return <ul>{files.map((f) => <li key={f.id}>{f.title}</li>)}</ul>;
}

External Dependencies​

react, react-dom, react/jsx-runtime, @onlyoffice/docspace-plugin-sdk/react, and @onlyoffice/apps-ui-kit must stay out of the plugin bundle — ONLYOFFICE Apps supplies them at load time.

Import only from @onlyoffice/apps-ui-kit; do not use subpath imports. The portal only substitutes the exact package specifier @onlyoffice/apps-ui-kit. A plugin that imports @onlyoffice/apps-ui-kit/components/button will fail to load with an error: "…which the portal does not provide."

// ✅ Correct
import { Button, Text } from "@onlyoffice/apps-ui-kit";

// ❌ Wrong — the portal cannot load this
import { Button } from "@onlyoffice/apps-ui-kit/components/button";

For the build configuration, see building a plugin.

Code samples are available at GitHub.