ExperimentalThe type of value this ref points to (defaults to unknown)
Readonly ExperimentaldocThe document handle this ref belongs to
Readonly ExperimentalpathThe resolved path segments
Optional Readonly ExperimentalrangeThe cursor range, if this ref points to a text range
Readonly ExperimentalrangeThe numeric positions of the range, if this is a range ref
Readonly ExperimentalurlThe URL representation of this ref
ExperimentalUpdate the value at this ref's path.
For primitives, you can pass either:
For objects and arrays, mutate them in place within the function (same semantics as Automerge). Returning new object/array instances will trigger a warning as it loses granular change tracking.
ExperimentalCheck if this ref contains another ref (other is a descendant of this).
ExperimentalCheck if this ref is equal to another ref. Two refs are equal if they have the same URL (document, path, and heads).
ExperimentalCheck if this ref is a child of another ref.
For arrays: only direct array elements are considered children (path must be exactly one segment longer).
For text: sub-ranges within the text are considered children (same path with a range, or one segment deeper).
ExperimentalCheck if this ref is equivalent to another ref. Two refs are equivalent if they point to the same value in the document, even if they use different addressing schemes (e.g., index vs pattern).
This is useful when you have refs created with different path types (e.g., by array index vs by object pattern match) and need to check if they resolve to the same location.
Short-circuits for fast rejection when refs are obviously different.
ExperimentalSubscribe to changes that affect this ref's value.
The callback is invoked whenever a change affects the value at this ref's path. It receives the new value and the change payload.
An unsubscribe function to stop listening
ExperimentalCheck if this ref overlaps with another ref (for text/range refs). Two refs overlap if they refer to the same parent location and their cursor ranges overlap.
ExperimentalRemove the value this ref points to from its parent container.
// Remove a property from an object
const nameRef = handle.ref('user', 'name');
nameRef.remove(); // deletes handle.doc().user.name
// Remove an item from an array
const todoRef = handle.ref('todos', 0);
todoRef.remove(); // removes first todo from array
// Remove text within a range
const rangeRef = handle.ref('text', cursor(0, 5));
rangeRef.remove(); // deletes first 5 characters
ExperimentalReturns the ref URL
ExperimentalGet the current value at this ref's path.
The value, or undefined if the path can't be resolved
ExperimentalReturns the ref URL
A reference to a location in an Automerge document.
This API is experimental and may change in future versions.
Example