
Setup
Step 1: Add Comment components
- Add the
Velt Commentscomponent to the root of your app. - This component is required to render comments in your app.
- Set the
text modeprop tofalseto hide the default text comment tool. - CKEditor selections are handled by
@veltdev/ckeditor-velt-comments. - Authenticate the user with
authProviderand set the Velt document before users add comments. - Add
VeltCommentsSidebarif you want a Google Docs-style comment sidebar.
- React / Next.js
Step 2: Install the Velt CKEditor extension
ckeditor5 is a peer dependency of the Velt CKEditor package and must be provided by your app. Import the CKEditor CSS once in your app so the editor and the Velt overlay render correctly.
- React / Next.js
Step 3: Configure the CKEditor editor with the Velt Comments plugin
AddVeltCommentsPlugin to the CKEditor plugins list and configure it with veltComments. Capture the editor instance from onReady, then render Velt comment annotations into that instance with renderComments.
- React / Next.js
Step 4: Add a comment button to your CKEditor editor
Add a button that users can click to add comments after selecting text in the CKEditor editor. Important: UseonMouseDown with preventDefault() so the browser does not move focus away from the editor before addComment reads the current selection. Keep the actual addComment call in onClick.
- React / Next.js
Step 5: Call addComment to add a comment
- Call this method to add a comment to selected text in the CKEditor editor.
- Params:
AddCommentRequest. It has the following properties:editor: CKEditor 5Editorinstance fromonReady.editorId: Id of the editor. Use this if you have multiple CKEditor editors on the same page. (optional)context:CommentAnnotationContextfor custom metadata to attach to the Comment Annotation. Learn more. (optional)
- Returns:
Promise<void>.
- React / Next.js
context.textEditorConfig with the selected text, its occurrence index in the document, and the editor ID when one is provided.
Step 6: Render comments in CKEditor editor
- Get the comment data from Velt SDK and render it in the CKEditor editor.
- Params:
RenderCommentsRequest. It has the following properties:editor: CKEditor 5Editorinstance.editorId: Id of the editor. Use this if you have multiple CKEditor editors on the same page. (optional)commentAnnotations: Array ofCommentAnnotationobjects.
- Returns:
void.
- React / Next.js
Step 7: Re-apply highlights after reloading content
Comment highlights are view-only overlay elements positioned over the commented text. They are not stored in the CKEditor document, so your saved HTML, schema, and undo history stay clean. Highlight positions are tracked with CKEditor model ranges and re-positioned as the document changes. CallrenderComments whenever the editor is recreated or its content is replaced. The useEffect in Step 6 handles this automatically when the editor instance or the annotation list changes.
Step 8: Style the commented text
- Comment highlights are rendered as
velt-comment-textoverlay markers. - You can override the marker styles in your app CSS.
Complete Example
APIs
VeltCommentsPlugin
The CKEditor 5 plugin that powers Velt comments. Add it to the<CKEditor> component’s config.plugins list and configure it with config.veltComments.
- Config:
VeltCommentsPluginConfig - Returns: CKEditor plugin class
- React / Next.js
addComment()
Creates a comment annotation for the currently selected text in CKEditor.- Signature:
async (request:AddCommentRequest) => Promise<void> - Params:
request:AddCommentRequest - Returns:
Promise<void>
- React / Next.js
renderComments()
Resolves and highlights Velt comment annotations in CKEditor.- Signature:
(request:RenderCommentsRequest) => void - Params:
request:RenderCommentsRequest - Returns:
void
- React / Next.js

