useNode()
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:| Name | Type | Default |
|---|---|---|
id | MaybeRefOrGetter<string | undefined>The id of the node to access (a value, ref, or getter; defaults to the node context id) |
the node id, the node (a ComputedRef), its dom element, its parent and connected edges
| Name | Type |
|---|---|
id | string |
nodeEl | ShallowRef<HTMLDivElement | null, HTMLDivElement | null> |
node | ComputedRef<NodeType | undefined> |
parentNode | ComputedRef<NodeType | undefined> |
connectedEdges | ComputedRef<Edge<Record<string, unknown>, string>[]> |
Notes
- The
idargument 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. nodeElis only populated whenuseNoderuns 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), thenodedata still resolves byid, butnodeElstaysnull. Note it always refers to the node you’re rendered in, not the node theidargument points at.