setupVueFlow()
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:| Name | Type | Default |
|---|---|---|
options | VueFlowProps<NodeType, EdgeType>initial flow options ( |
Notes
- Call
setupVueFlowin a componentsetup— it relies on Vue’sprovide, 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.