Comments
Use comments to discuss tasks, orders, and other records. A comment remains attached to its record in the Grid, Kanban, Gallery, Calendar, and Gantt views, and switching views does not create a separate discussion.
Register the plugins
Register the following plugins after the Bases core and UI plugins:
pnpm add @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/bases-thread-comment @univerjs-pro/bases-thread-comment-uinpm install @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/bases-thread-comment @univerjs-pro/bases-thread-comment-uiyarn add @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/bases-thread-comment @univerjs-pro/bases-thread-comment-uibun add @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/bases-thread-comment @univerjs-pro/bases-thread-comment-uiimport { UniverBasesThreadCommentPlugin } from '@univerjs-pro/bases-thread-comment'import { UniverBasesThreadCommentUIPlugin } from '@univerjs-pro/bases-thread-comment-ui'import ProductLocale from '@univerjs-pro/bases-thread-comment-ui/locale/en-US'import { LocaleType, mergeLocales } from '@univerjs/core'import SharedLocale from '@univerjs/thread-comment-ui/locale/en-US'import '@univerjs-pro/bases-thread-comment/facade'import '@univerjs/thread-comment/facade'import '@univerjs/thread-comment-ui/lib/index.css'import '@univerjs-pro/bases-thread-comment-ui/lib/index.css'univerAPI.loadLocales(LocaleType.EN_US, mergeLocales(SharedLocale, ProductLocale))univer.registerPlugin(UniverBasesThreadCommentPlugin)univer.registerPlugin(UniverBasesThreadCommentUIPlugin)Merge the locale resources from the comment packages, and configure the current user for the application. The UI plugin adds comment controls to records, and the data plugin associates comments with records.
Add and read comments
const record = univerAPI.getActiveBase()?.getTables()[0]?.getRecords()[0]if (!record) throw new Error('Create a record first')await record.createCommentAsync('Please confirm the delivery date.')const comments = record.getComments()console.log(comments.map(({ root }) => root.id))getComments() returns the comments that are already loaded locally. With a remote data source, await record.listCommentsAsync() synchronizes the threads it already knows about before returning them. Replies, updates, and deletion are described in comment Facade.
Saving and shared discussions
Comments created locally are saved as part of the Base resources when the application calls base.save(). Register the comment plugins before restoring a snapshot.
Shared discussions also require a comment service, a data source, and permissions. Document collaboration alone does not connect comments. Configure the Office extension modules first, then verify creation, reading, permissions, and reopening with two accounts.
Shared comment operations
Import both the shared comment Facade and the product Facade before calling these methods. The product helpers create stable anchors, and the shared API handles replies, updates, resolution, and deletion. getComments() reads local state, while listCommentsAsync() synchronizes the threads it already knows through the configured data source; it does not discover every thread on the server.
import '@univerjs/thread-comment/facade'const [thread] = univerAPI.getComments({ resolved: false })if (thread) { await univerAPI.replyCommentAsync({ unitId: thread.unitId, subUnitId: thread.subUnitId, threadId: thread.threadId, content: 'Reviewed.', })}Shared discussions
To enable shared discussions, integrate the Comment Service and Endpoint through the Server SDK, then register UniverThreadCommentDataSourcePlugin from @univerjs-pro/thread-comment-datasource after collaboration and the license are configured. The bundled data source calls /universer-api/comment/unit/{unitId}/... and /universer-api/user/list, so the application must expose these routes. Server permissions must control comment reads and writes independently of document editing.
How is this guide?