Skip to Content
Svelte Flow 2 is out! Read the announcement →
ReferenceHooks

useNodesData()

Source on GitHub 

With this hook you can receive the data of the passed node ids.

<script lang="ts"> import { useNodesData } from '@xyflow/svelte'; const nodeData = useNodesData(() => ({ nodeIds: ['node-id-a', 'node-id-b'] })); $effect(() => { // nodeData changes whenever the data of the passed node ids get updated console.log(nodeData.current); }); </script>

Signature

Parameters:
NameTypeDefault
params() => { nodeIds: string | null | undefined; }

A function that returns the node id(s) to get the data from

Returns:

An array of data objects

NameType
currentDistributivePick<NodeType, "id" | "data" | "type"> | null

Notes