useConnection()
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.valuein script, or bind it directly in a template. - The
toendpoint is given in flow coordinates.