Skip to main content
This is a comprehensive tutorial for building a complete visual workflow application with React. For a quick 5-minute intro, see Visual Builder Quick Start.
In this tutorial, you’ll build a fully-featured workflow builder application with:
  • Multiple custom nodes (input, math, display)
  • Visual drag-and-drop interface
  • Property editing panel
  • Save/load functionality
  • Execution with progress feedback
  • Error handling
Time Required: 30-45 minutes

What We’ll Build

A calculator workflow app where users can:
  1. Add number input nodes and set values
  2. Drag math operation nodes (add, multiply, subtract)
  3. Connect nodes visually
  4. Execute the workflow and see results
  5. Save/load workflows as JSON
Complete Workflow Builder

Prerequisites

  • Node.js 18+ installed
  • Basic React knowledge
  • Familiarity with TypeScript

Step 1: Create React Project

We’ll use Vite for fast development:

Step 2: Install CrystalFlow

Step 3: Configure TypeScript

Update tsconfig.json to enable decorators:
tsconfig.json

Step 4: Create Custom Nodes

Create a src/nodes directory for your workflow nodes.

Number Input Node

src/nodes/NumberInputNode.ts

Math Nodes

src/nodes/MathNodes.ts

Display Node

src/nodes/DisplayNode.ts

Export All Nodes

src/nodes/index.ts

Step 5: Create the Main App Component

Now let’s create the React component that uses CrystalFlow’s visual builder:
src/App.tsx

Step 6: Add Styling

Create src/App.css:
src/App.css

Step 7: Update Main Entry Point

Update src/main.tsx:
src/main.tsx

Step 8: Run Your App

Open http://localhost:5173 in your browser!

Using Your Workflow Builder

1

Add Nodes

Drag nodes from the left palette onto the canvas. Try adding:
  • Two Number Input nodes
  • One Add node
  • One Display node
2

Set Values

Click a Number Input node to select it. In the right property panel, set its value (e.g., 5 and 3).
3

Connect Nodes

Drag from the output handle (right side, blue dot) of Number Input to the input handle (left side) of the Add node. Connect both inputs.
4

Connect Display

Connect the Add node’s Result output to the Display node’s Value input.
5

Execute

Click the ▶️ Execute button in the toolbar. Check the console and results panel!

Adding Features

Save and Load Workflows

Add save/load handlers:

Add Progress Tracking

Display Node Results

Show output values from each node:

What You’ve Built

✅ Complete visual workflow builder UI
✅ Drag-and-drop node palette
✅ Visual node connections
✅ Property editing panel
✅ Workflow execution with feedback
✅ Custom math and display nodes
✅ Error handling and status display

Next Steps

Creating Custom Nodes

Build more powerful custom nodes

Execution & Events

Master workflow execution

Serialization

Save/load workflows properly

Examples

See more complete examples

Troubleshooting

Make sure all node classes have the @defineNode decorator and are passed to the nodes prop.
Verify port types match. An output of type 'number' can only connect to an input of type 'number' or 'any'.
Properties use @Property decorator, not @Input. Inputs are for connections, properties are for configuration.
Check the browser console for errors. Add the onError callback to capture errors.