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

useNodeId()

Source on GitHub 

The useNodeId composable returns the id of the node a component is rendered in. It reads the node context that Vue Flow provides around every custom node, so it only returns a value when called inside a custom node (or one of its descendants) — otherwise it returns null.

<!-- inside a custom node or a child of one --> <script setup lang="ts"> import { useNodeId } from '@xyflow/vue'; const nodeId = useNodeId(); </script>

Signature

Parameters:

This function does not accept any parameters.

Returns:
string | null

the current node id