
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
textModeprop tofalseto hide the default text comment tool.
- React / Next.js
Step 2: Install the Velt SuperDoc extension
window and the DOM. Import its stylesheet globally, then dynamically import the SuperDoc SDK and Velt extension inside a client-side effect.
Step 3: Configure the SuperDoc editor with the Velt Comments extension
Create the SuperDoc editor, disable SuperDoc’s built-in comments, then attachSuperDocVeltComments from the editor’s onReady callback.
- React / Next.js
Step 4: Add a comment button to your SuperDoc editor
Add a button users can click after selecting text in the SuperDoc editor. UseonMouseDown with preventDefault() so clicking the button does not clear the current editor selection before addComment reads it. 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 SuperDoc editor.
- Params:
AddCommentArgs. It has the following properties:instance: SuperDoc editor instance returned bynew SuperDoc(...).
- Returns:
Promise<AddCommentResult | null>. It returnsnullif no text is selected or Velt is not loaded.
- React / Next.js
Step 6: Render comments in the SuperDoc editor
- Get the comment data from Velt SDK and render it in the SuperDoc editor.
- Params:
RenderCommentsArgs. It has the following properties:instance: SuperDoc editor instance.commentAnnotations: Array of Comment Annotation objects.
- React / Next.js
TextEditorConfig anchor and remaps live ranges as the document changes. You do not need to call renderComments on every edit, scroll, zoom, or resize. Re-run it when Velt’s annotation list changes.
Step 7: Clean up the SuperDoc extension
SuperDocVeltComments.configure(...).attach(instance) returns an AttachedExtension. Call detach() in your effect cleanup to remove listeners, clear per-instance state, and remove overlay elements before destroying the editor.
Step 8: Style the commented text
- You can style commented text by adding CSS for the
velt-comment-textelement. - SuperDoc highlights are light-DOM overlay elements inside
div.velt-superdoc-overlay-root, so a global stylesheet can reach them. - The default highlight rules use inline
!importantstyles, so overrides should use!important.
Complete Example
APIs
SuperDocVeltComments
Creates the Velt Comments extension for a SuperDoc editor. UseSuperDocVeltComments.configure(...).attach(instance) to attach it to an editor instance.
- Config:
SuperDocVeltCommentsConfig - Returns:
SuperDocVeltComments
- React / Next.js
addComment()
Creates a comment annotation for the currently selected text in the SuperDoc editor.- Signature:
async (args: AddCommentArgs) => Promise<AddCommentResult | null> - Params:
args:AddCommentArgs - Returns:
Promise<AddCommentResult | null>; seeAddCommentResult.
- React / Next.js
renderComments()
Renders and updates Velt comment highlights in the SuperDoc editor.- Signature:
(args:RenderCommentsArgs) => void - Params:
args:RenderCommentsArgs - Returns:
void
- React / Next.js

