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

addEdge()

Source on GitHub 

The addEdge util is a convenience function to add a new Edge to an array of edges. It also validates the edge so you don’t add an invalid one or duplicate an existing connection.

import { addEdge } from '@xyflow/vue'; function onConnect(connection) { edges.value = addEdge(connection, edges.value); }

Signature

Parameters:
NameTypeDefault
edgeParamsEdgeType | Connection
edgesEdgeType[]
options.getEdgeIdGetEdgeId

Custom function to generate edge IDs. If not provided, the default getEdgeId function is used.

options.onErrorOnError

Called when edge validation fails. If not provided, a default dev warning is used.

Returns:

Notes

  • If an edge with the same source and target already exists (and the same sourceHandle / targetHandle when set), addEdge won’t add another one — even if the id differs.