Skip to main content
SuperDoc has two navigation approaches depending on your use case: scrollToElement takes any element ID — paragraph, comment, or tracked change — and scrolls to it. Use doc.extract() to get all IDs at once, or query.match for targeted lookups.
This is the approach to use for:
  • RAG citations — store nodeId alongside embeddings, navigate on click
  • Cross-references — link to specific paragraphs from external UI
  • Search results — scroll to the matching paragraph
  • Cross-session addressing — IDs from DOCX-imported content survive reloads
For the full extraction pattern, see content extraction for RAG. For the cross-session pattern, see cross-session block addressing.

Track nodes during edits

When users edit a document, stored positions can drift. Use PositionTracker so navigation targets stay stable within the current session.

Best practices

  • Use scrollToElement when you have an element ID from doc.extract() or the Document API.
  • Use PositionTracker when you need to follow nodes that move during edits.
  • For cross-session use, store nodeId values (not sdBlockId — those regenerate on each open).
  • Handle missing targets gracefully — both APIs return false if the element no longer exists.