Velt CRDT Best Practices
Comprehensive best practices guide for implementing real-time collaborative editing with Velt CRDT (Yjs), maintained by Velt. Contains 38 rules across 5 categories, prioritized by impact to guide automated code generation and debugging.
When to Apply
Reference these guidelines when:
- Setting up Velt client and CRDT stores
- Integrating with Tiptap, BlockNote, CodeMirror, or ReactFlow
- Implementing real-time synchronization
- Managing version history and checkpoints
- Debugging collaboration or sync issues
- Testing multi-user collaboration
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Core CRDT | CRITICAL | core- |
| 2 | Tiptap Integration | CRITICAL | tiptap- |
| 3 | BlockNote Integration | HIGH | blocknote- |
| 4 | CodeMirror Integration | HIGH | codemirror- |
| 5 | ReactFlow Integration | HIGH | reactflow- |
Quick Reference
1. Core CRDT (CRITICAL)
core-install- Install correct CRDT packages for your frameworkcore-velt-init- Initialize Velt client before creating storescore-store-create-react- Use useVeltCrdtStore hook for Reactcore-store-create-vanilla- Use createVeltStore for non-Reactcore-store-types- Choose correct store type (text/array/map/xml)core-store-subscribe- Subscribe to store changes for remote updatescore-store-update- Use update() method to modify valuescore-version-save- Save named version checkpointscore-encryption- Use custom encryption provider for sensitive datacore-webhooks- Use webhooks to listen for CRDT data changescore-rest-api- Use REST API to retrieve CRDT data server-sidecore-activity-debounce- Use setActivityDebounceTime() to control how frequently batched CRDT editor activities are flushedcore-activity-action-types- Use CrdtActivityActionTypes constant for type-safe CRDT activity filtering instead of raw stringscore-message-stream- Use CrdtElement message-stream methods (pushMessage, onMessage, getMessages, getSnapshot, saveSnapshot, pruneMessages) for Yjs-backed collaborative editorscore-debug-storemap- Use VeltCrdtStoreMap for runtime debuggingcore-debug-testing- Test with multiple browser profiles
2. Tiptap Integration (CRITICAL)
tiptap-install- Install Tiptap CRDT packagestiptap-setup-react- Use useVeltTiptapCrdtExtension for Reacttiptap-setup-vanilla- Use createVeltTipTapStore for non-Reacttiptap-disable-history- Disable Tiptap history to prevent conflictstiptap-editor-id- Use unique editorId per instancetiptap-cursor-css- Add CSS for collaboration cursorstiptap-testing- Test collaboration with multiple users
3. BlockNote Integration (HIGH)
blocknote-install- Install BlockNote CRDT packageblocknote-setup-react- Use useVeltBlockNoteCrdtExtensionblocknote-editor-id- Use unique editorId per instanceblocknote-testing- Test collaboration with multiple users
4. CodeMirror Integration (HIGH)
codemirror-install- Install CodeMirror CRDT packagescodemirror-setup-react- Use useVeltCodeMirrorCrdtExtension for Reactcodemirror-setup-vanilla- Use createVeltCodeMirrorStore for non-Reactcodemirror-ycollab- Wire yCollab extension with store's Yjs objectscodemirror-editor-id- Use unique editorId per instancecodemirror-testing- Test collaboration with multiple users
5. ReactFlow Integration (HIGH)
reactflow-install- Install ReactFlow CRDT packagereactflow-setup-react- Use useVeltReactFlowCrdtExtensionreactflow-handlers- Use CRDT handlers for node/edge changesreactflow-editor-id- Use unique editorId per instancereactflow-testing- Test collaboration with multiple users
How to Use
Read individual rule files for detailed explanations and code examples:
rules/shared/core/core-install.md
rules/shared/tiptap/tiptap-disable-history.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Verification checklist
- Source pointer to Velt documentation
Compiled Documents
AGENTS.md— Compressed index of all rules with file paths (start here)AGENTS.full.md— Full verbose guide with all rules expanded inline