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

useEdge()

Source on GitHub 

The useEdge composable returns the Edge for a given id along with its DOM element. Inside a custom edge the id defaults to the current edge, so you can call it with no arguments.

<!-- CustomEdge.vue --> <script setup lang="ts"> import { useEdge } from '@xyflow/vue'; const { edge, edgeEl } = useEdge(); </script>

Signature

Parameters:
NameTypeDefault
idstring

The id of the edge to access

Returns:

the edge id, the edge (a ComputedRef) and the edge dom element

NameType
idstring
edgeComputedRef<EdgeType | undefined>
edgeElShallowRef<SVGElement | null, SVGElement | null>

Notes

  • edgeEl is only populated when useEdge runs inside a custom edge (or a descendant of one) — it’s injected from the surrounding edge’s component. Called from anywhere else, the edge data still resolves by id, but edgeEl stays null. Note it always refers to the edge you’re rendered in, not the edge the id argument points at.