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

useNode()

Source on GitHub 

The useNode composable returns the user-facing Node for a given id, along with its DOM element, parent node, and connected edges. Inside a custom node the id defaults to the current node, so you can call it with no arguments.

<!-- CustomNode.vue --> <script setup lang="ts"> import { useNode } from '@xyflow/vue'; // id defaults to the current node const { node, connectedEdges } = useNode(); </script>

Signature

Parameters:
NameTypeDefault
idMaybeRefOrGetter<string | undefined>

The id of the node to access (a value, ref, or getter; defaults to the node context id)

Returns:

the node id, the node (a ComputedRef), its dom element, its parent and connected edges

NameType
idstring
nodeElShallowRef<HTMLDivElement | null, HTMLDivElement | null>
nodeComputedRef<NodeType | undefined>
parentNodeComputedRef<NodeType | undefined>
connectedEdgesComputedRef<Edge<Record<string, unknown>, string>[]>

Notes

  • The id argument is reactive — pass a ref or getter and the result tracks it.
  • For the enriched internal node (measured size, absolute position, handle bounds) use useInternalNode() instead.
  • nodeEl is only populated when useNode runs inside a custom node (or a descendant of one) — it’s injected from the surrounding node’s component. Called from anywhere else (a sidebar, a toolbar, a provider-scoped component), the node data still resolves by id, but nodeEl stays null. Note it always refers to the node you’re rendered in, not the node the id argument points at.