Live Demo
View the live demo on vueflow.dev.Complete Example
Key Concepts
Validation Functions
Validation functions determine whether a connection is allowed. They receive a connection object and return a boolean:Node-Level Validation
Set validation on individual nodes:Handle-Level Validation
Pass validation to individual handles:Validation Types
- isValidSourcePos
- isValidTargetPos
- Handle Validation
Validates when this node is the source of a connection:
Connection Events
Listen to connection events to track connection attempts:Advanced Validation
Prevent Self-Connections
Validate by Node Type
Limit Number of Connections
Validate Handle Connections
Visual Feedback
Provide visual feedback for invalid connections using CSS:Global Validation
Set validation for all connections:TypeScript Support
Best Practices
- Combine node-level and handle-level validation for fine-grained control
- Provide visual feedback when connections are invalid
- Use TypeScript for type-safe validation functions
- Consider performance when validating in large graphs
Example Use Cases
- Type-safe connections: Only allow certain node types to connect
- Direction enforcement: Enforce data flow direction (e.g., input → processing → output)
- Cycle prevention: Prevent circular dependencies
- Capacity limits: Limit the number of connections per node
- Handle matching: Ensure compatible handles connect (e.g., data types)
Next Steps
Custom Nodes
Create custom node components
Drag and Drop
Add nodes via drag and drop
Connection API
Connection type reference
Events
Learn about all available events