The Suggestions API lets you wire any DOM element as a suggestion target. When suggestion mode is active, the SDK captures before/after values, persists them as typedDocumentation Index
Fetch the complete documentation index at: https://velt-v5-0-2-beta-23.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Suggestion annotations, and surfaces accept/reject actions on the comment dialog. Approving fires a suggestionApproved event your app handles to apply the change.
Key Concepts
- Suggestion target: Any DOM element tagged with
data-velt-suggestion-target="<targetId>". - Suggestion mode: When enabled, the SDK listens for edits on registered targets and wraps them as pending suggestions rather than committing them immediately.
- Suggestion lifecycle:
pending→approved/rejected/stale/apply_failed. - SuggestionElement: The singleton object returned by
client.getSuggestionElement()(HTML/Vanilla) or theuseSuggestionUtils()hook (React). All Suggestions API methods live on this object.
How It Works
- Register one or more DOM elements as suggestion targets using
registerTarget(). - Enable suggestion mode via
enableSuggestionMode(). - The SDK intercepts edits, captures before/after values, and creates a pending
Suggestionbacked by aCommentAnnotationwithtype === 'suggestion'. - The accept/reject actions appear in the comment dialog. Accepting fires
suggestionApproved; your handler applies the change to your data.
Data Model
Suggestions are stored asCommentAnnotation objects with type === 'suggestion' and a populated suggestion field. The full type hierarchy lives in the Suggestions section of the Data Models reference.
Behavior Notes
- Stale wins over drift: If the target DOM node cannot be resolved at approve time, the suggestion transitions to
staleimmediately and drift detection is skipped. - Drift detection is best-effort: On approve, if a getter is registered, the live value is compared against
oldValue. A mismatch setsdriftDetected: trueon the suggestion. v1 records the flag; a future release will surface a confirmation prompt. - One suggestion per edit session: For text-like inputs, one suggestion is captured per focus session (
focusout). For atomic inputs (e.g.,<select>), one suggestion is captured perchangeevent. - Mode is not persisted: Suggestion mode is per-user-per-session. A page reload returns suggestion mode to disabled.

