Skip to Content
Vue Flow v2 is here and joins xyflow! Read more here →
ReferenceComposables

setupVueFlow()

Source on GitHub 

The setupVueFlow composable creates a Vue Flow store, provides it to the current component’s subtree, and returns the flow instance (the same shape as useVueFlow()). It is the composable alternative to the <VueFlowProvider /> component — use it when you own the surrounding component and want to set up and access the flow from one <script setup>.

<script setup lang="ts"> import { setupVueFlow, VueFlow } from '@xyflow/vue'; // creates + provides the store, and returns the instance const { getNodes, fitView } = setupVueFlow(); </script> <template> <VueFlow v-model:nodes="nodes" v-model:edges="edges" /> <Sidebar /> </template>

Signature

Parameters:
NameTypeDefault
optionsVueFlowProps<NodeType, EdgeType>

initial flow options (id, initial nodes/edges, defaults, …)

Returns:
VueFlowInstance<NodeType, EdgeType>

the VueFlow instance (same shape useVueFlow() returns)

Notes

  • Call setupVueFlow in a component setup — it relies on Vue’s provide, so the store is only available to that component and its descendants.
  • Child components then reach the same store with useVueFlow() / useVueFlowStore(), without passing anything down.
  • You can pass initial options (the same props as <VueFlow />) to seed the store.