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

useConnection()

Source on GitHub 

The useConnection composable returns the current connection while there is an active connection interaction. When no connection is in progress it reports inProgress: false with null fields. A typical use is to colorize handles based on whether the connection is valid.

<script setup lang="ts"> import { useConnection } from '@xyflow/vue'; const connection = useConnection(); // connection.value.inProgress, connection.value.fromHandle, connection.value.isValid, ... </script>

Signature

Parameters:

This function does not accept any parameters.

Returns:
ComputedRef<ConnectionState<InternalNode<NodeType>>>

a ComputedRef<ConnectionState> — inProgress: false (all-null fields) when idle

Notes

  • The returned value is a computed ref — read it as connection.value in script, or bind it directly in a template.
  • The to endpoint is given in flow coordinates.