useNodesInitialized()
The useNodesInitialized composable returns a reactive boolean that becomes true once
every node has been measured — i.e. its dimensions and handle bounds are known. It’s
the signal to wait for before doing work that needs the real, measured node sizes,
such as running your own layout.
<script setup lang="ts">
import { watch } from 'vue';
import { useNodesInitialized, useVueFlow } from '@xyflow/vue';
const nodesInitialized = useNodesInitialized();
const { getNodes, setNodes } = useVueFlow();
// lay the graph out once every node has real measured dimensions
watch(nodesInitialized, (initialized) => {
if (initialized) {
setNodes(layout(getNodes.value));
}
});
</script>Signature
Parameters:| Name | Type | Default |
|---|
Notes
- Hidden nodes are ignored unless you pass
{ includeHiddenNodes: true }. fitView()already waits for measurement internally, so you often don’t need this composable just to fit the view — reach for it when you have your own layout or measurement-dependent logic.