
Plate.js is a React-only framework. This guide covers the React integration only.
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.
- React / Next.js
Step 2: Install the Velt Plate extension
Step 3: Configure the Plate editor with the Velt Comments extension
- Import
VeltCommentsPluginand add it to your Plate editor’s plugins array.
- React / Next.js
Step 4: Add a comment button to your Plate editor
- Add a button that users can click to add comments after selecting text.
- Use
onMouseDownwithpreventDefaultto preserve the editor selection when clicking the button.
- React / Next.js
Step 5: Call addComment to add a comment
- Call this method to add a comment to selected text in the Plate editor. You can use this when the user clicks on the comment button or presses a keyboard shortcut.
- Params:
AddCommentRequest. It has the following properties:editor: Instance of the Plate editor.editorId: Id of the Plate editor. Use this if you have multiple Plate editors on the same page in your app. (optional)context: Add any custom metadata to the Comment Annotation. Learn more. (optional)
- React / Next.js
Step 6: Render comments in Plate editor
- Get the comment data from Velt SDK using the
useCommentAnnotationshook and render it in the Plate editor. - Params:
RenderCommentsRequest. It has the following properties:editor: Instance of the Plate editor.editorId: Id of the Plate editor. Use this if you have multiple Plate editors on the same page in your app. (optional)commentAnnotations: Array of Comment Annotation objects.
- React / Next.js
Step 7: Persist Velt Comment Marks (optional)
- By default, Velt comment marks are persisted by the Velt SDK. When the editor loads and the Velt SDK initializes, the marks will be automatically added to the editor.
- If you plan to store the contents of the Plate editor on your end with the comment marks already included, you can disable this feature.
- Default:
true
Step 8: Style the commented text
- You can style the commented text by adding CSS for the
velt-comment-textelement.
APIs
VeltCommentsPlugin.configure()
A Plate.js plugin for Velt Comments integration.- Params:
options?:VeltCommentsPluginConfigeditorId?: string- Unique identifier for this editor instance (for multi-editor scenarios).persistVeltMarks?: boolean- Whether to persist Velt marks. Default:true.
- Returns: Plate Plugin
- React / Next.js
addComment()
Creates a comment annotation for the currently selected text in the editor.- Params:
request:AddCommentRequesteditor: PlateEditoreditorId?: stringcontext?: object
- Returns:
Promise<void>
- React / Next.js
renderComments()
Renders and highlights comment annotations in the editor.- Params:
request:RenderCommentsRequesteditor: PlateEditoreditorId?: stringcommentAnnotations?:CommentAnnotation[]
- Returns:
void
- React / Next.js
exportJSONWithoutComments()
Exports the editor content as JSON with Velt comment elements removed. Useful when saving content to your backend without comment markup.- Params:
content: Descendant[]- The editor content (Slate nodes). - Returns:
Descendant[]- Content with comment elements removed.
- React / Next.js
PlateVeltComment
React component for rendering Velt comment elements in the editor. This is automatically used by the plugin, but can be referenced for custom render element implementations.- React / Next.js

