useNodesData()
The useNodesData composable returns the data of one or more nodes by id, along with
each node’s id and type. It is shallow-compared, so it only re-runs when the
referenced nodes’ data actually changes — handy for reading upstream nodes’ data
inside a custom node without re-rendering on unrelated updates.
<script setup lang="ts">
import { useNodesData } from '@xyflow/vue';
// single id -> object | null
const upstream = useNodesData('node-1');
// array of ids -> array of results
const many = useNodesData(['node-1', 'node-2']);
</script>Signature
Parameters:
Returns:
| Name | Type | Default |
|---|---|---|
nodeId | MaybeRefOrGetter<string>The id (or ids) of the node to get the data from |
ComputedRef<DistributivePick<NodeType, "id" | "type" | "data"> | null>An object (or array of objects) with id, type, data representing each node
Notes
- Pass a single id to get an object (or
null); pass an array to get an array. - The result is read-only.