react-flow
Skill91 starsChanged 4 days agoApache-2.0View on GitHub
Implements and structures node-based UIs with React Flow (@xyflow/react v12/v13), covering custom nodes and edges, handles, viewport control, sub-flows, store subscriptions, and @dagrejs/dagre auto-layout. Use when building flow editors, workflow diagrams, or interactive graphs in React.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- udaykumar-dhokia/mcp-flowtheir own version, first seen Nov 15, 2026
- fatih-developer/fth-skillstheir own version, first seen Oct 13, 2026
- noeltock/react-flowtheir own version, first seen Oct 13, 2026
- SnowBeatRain/skillstheir own version, first seen Oct 12, 2026
- framara/react-flow-skilltheir own version, first seen Sep 28, 2026
- ryonakae/sheltietheir own version, first seen Aug 4, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- shep-ai/shep★ 291same name
- framara/react-flow-skill★ 55same name
- fatih-developer/fth-skills★ 7same name
- SnowBeatRain/skills★ 3same name
- udaykumar-dhokia/mcp-flow★ 2same name
- ryonakae/sheltie★ 1same name
- noeltock/react-flow★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository85 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- agent-architecture-analysisSkill
- app-intents-code-reviewSkill
- artifact-analysisSkill
- axum-code-reviewSkill
- brainstorm-beagleSkill
- bubbletea-code-reviewSkill
- cloudkit-code-reviewSkill
- elixir-performance-reviewSkill
- elixir-security-reviewSkill
- elixir-writing-docsSkill
- exdoc-configSkill
- exunit-code-reviewSkill
- fastapi-code-reviewSkill
- fetch-pr-feedbackSkill
- ffi-code-reviewSkill
- fix-llm-artifactsSkill
- fowler-refactoringSkill
- gen-test-planSkill
- go-architectSkill
- go-code-reviewSkill
- go-data-persistenceSkill
- go-testing-code-reviewSkill
- healthkit-code-reviewSkill
- humanize-beagleSkill
- improve-docSkill
- ios-animation-code-reviewSkill
- liveview-code-reviewSkill
- llm-artifacts-detectionSkill
- llm-judgeSkill
- macros-code-reviewSkill
- phoenix-code-reviewSkill
- postgres-code-reviewSkill
- prfaq-beagleSkill
- prometheus-go-code-reviewSkill
- pytest-code-reviewSkill
- quick-planSkill
- react-flow-code-reviewSkill
- react-router-code-reviewSkill
- react-router-v7Skill
- receive-feedbackSkill
- refactor-repoSkill
- resolve-beagleSkill
- respond-pr-feedbackSkill
- review-ai-writingSkill
- review-elixirSkill
- review-frontendSkill
- review-goSkill
- review-iosSkill
- review-llm-artifactsSkill
- review-planSkill
- review-pythonSkill
- review-remix-v2Skill
- review-rustSkill
- review-skillSkill
- review-structureSkill
- review-tuiSkill
- review-verification-protocolSkill
- run-test-planSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 1 is distinctive, and 6 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Run these checks in order before treating any integration as complete:
- Very specific: line 93
Typed props: Use NodeProps<TaskNode> and EdgeProps<WeightedEdge>, wrapped in memo().
- Very specific: line 94
Handles: Always use Position enum (Position.Top, Position.Right, Position.Bottom, Position.Left).
- Very specific: line 107
Prefer useReactFlow().updateNodeData / updateEdgeData over manually mapping the full nodes/edges array for data-only updates:
- Very specific: line 122
Use reconnectEdge with onReconnect (replaced v11's updateEdge utility):
- Very specific: line 191
< 100 nodes: Default <ReactFlow /> settings.
- Very specific: line 194
10k+ nodes / static / 3D: Consider WebGL graph renderers (e.g., Sigma.js) for 10k+ nodes, plain SVG/Canvas for static diagrams, or Three.js …
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Flow (@xyflow/react)
Implement interactive node-based graphs and workflow editors using @xyflow/react (v12 and v13, React 18/19).
Implementation Gates
Run these checks in order before treating any integration as complete:
- CSS & container dimensions — Import
@xyflow/react/style.css(v13, wrapped in@layer xyflowfor Tailwind v4 precedence) or@xyflow/react/dist/style.css(v12), and give the wrapper element explicit dimensions (widthandheight). - Stable
nodeTypes/edgeTypes— DefinenodeTypesandedgeTypesat module scope or memoize withuseMemo; never create inline object literals on every render (causes full node/edge remounting). - Provider boundary — Any component calling
useReactFlow(),useNodesData(),useNodeConnections(), or store hooks must be a descendant of<ReactFlowProvider>(or rendered inside<ReactFlow />). - Measured vs SSR dimensions — Read DOM-measured node sizes from
node.measured?.width/node.measured?.height(falling back tonode.width ?? defaultWidth). For SSR/SSG, provide staticwidth/heightorinitialWidth/initialHeighton nodes sofitViewand initial layout work without DOM measurement.
Quick Start & TypeScript Unions
import { useCallback } from 'react';
import {
ReactFlow,
ReactFlowProvider,
Background,
Controls,
useNodesState,
useEdgesState,
addEdge,
type Node,
type Edge,
type BuiltInNode,
type BuiltInEdge,
type OnConnect,
} from '@xyflow/react';
import '@xyflow/react/style.css'; // v13 (@layer xyflow); use '@xyflow/react/dist/style.css' on v12
export type TaskNode = Node<{ label: string; active: boolean }, 'task'>;
export type AppNode = BuiltInNode | TaskNode;
export type WeightedEdge = Edge<{ weight: number }, 'weighted'>;
export type AppEdge = BuiltInEdge | WeightedEdge;
const nodeTypes = { /* task: TaskNodeComponent */ };
const edgeTypes = { /* weighted: WeightedEdgeComponent */ };
const initialNodes: AppNode[] = [
{ id: '1', type: 'input', position: { x: 0, y: 0 }, data: { label: 'Start' } },
{ id: '2', position: { x: 240, y: 80 }, data: { label: 'Process' } },
];
const initialEdges: AppEdge[] = [{ id: 'e1-2', source: '1', target: '2' }];
function FlowCanvas() {
const [nodes, setNodes, onNodesChange] = useNodesState<AppNode>(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState<AppEdge>(initialEdges);
const onConnect: OnConnect = useCallback(
(connection) => setEdges((eds) => addEdge(connection, eds)),
[setEdges]
);
return (
<div style={{ width: '100%', height: '100vh' }}>
<ReactFlow
nodes={nodes}
edges={edges}
nodeTypes={nodeTypes}
edgeTypes={edgeTypes}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onConnect={onConnect}
fitView
>
<Background />
<Controls />
</ReactFlow>
</div>
);
}
export default function App() {
return (
<ReactFlowProvider>
<FlowCanvas />
</ReactFlowProvider>
);
}Custom Nodes, Edges & Interaction Classes
- Typed props: Use
NodeProps<TaskNode>andEdgeProps<WeightedEdge>, wrapped inmemo(). ImportCSSPropertiesfrom'react'(not'@xyflow/react'). - Handles: Always use
Positionenum (Position.Top,Position.Right,Position.Bottom,Position.Left). Assign distinctidprops when a node has multiple handles of the same type, and match them viasourceHandle/targetHandleon edges. - Interaction classes: Prevent accidental graph interactions on embedded controls:
nodrag— prevents dragging the node (required on<input>,<button>,<select>)nopan— prevents canvas panning from the elementnowheel— prevents canvas zoom on scroll inside scrollable areasnokey— prevents React Flow keyboard shortcuts (backspace/delete) when typing in inputs
For multi-handle nodes, dynamic handles (useUpdateNodeInternals), NodeToolbar, NodeResizer, EdgeToolbar, Panel, BaseEdge, EdgeLabelRenderer, EdgeText, MarkerType, and onBeforeDelete, see Custom Primitives.
Core APIs & Patterns
Updating Node/Edge Data & Reconnecting
Prefer useReactFlow().updateNodeData / updateEdgeData over manually mapping the full nodes/edges array for data-only updates:
const { updateNodeData, setEdges } = useReactFlow<AppNode, AppEdge>();
// Merge partial data (or pass { replace: true } as 3rd arg); generics live on useReactFlow<AppNode, AppEdge>()
updateNodeData('node-1', { active: true });
// Functional updater on union AppNode: narrow node.type before reading custom fields
updateNodeData('node-1', (node) => {
if (node.type !== 'task') return node.data;
return { ...node.data, active: !node.data.active };
});Use reconnectEdge with onReconnect (replaced v11's updateEdge utility):
import { reconnectEdge, type OnReconnect } from '@xyflow/react';
const onReconnect: OnReconnect<AppEdge> = useCallback(
(oldEdge, newConnection) => setEdges((els) => reconnectEdge(oldEdge, newConnection, els)),
[setEdges]
);Connection Validation
isValidConnection receives Connection | Edge:
import type { Connection, Edge } from '@xyflow/react';
const isValidConnection = useCallback(
(connection: Connection | Edge) => connection.source !== connection.target,
[]
);Viewport, Coordinates & Serialization
const {
fitView,
setCenter,
getNode,
screenToFlowPosition,
toObject,
setViewport,
viewportInitialized,
} = useReactFlow();
// Pan to a measured node center (use node.measured, not bare node.width)
const focusNode = (id: string) => {
const node = getNode(id);
if (!node) return;
const w = node.measured?.width ?? node.width ?? 0;
const h = node.measured?.height ?? node.height ?? 0;
setCenter(node.position.x + w / 2, node.position.y + h / 2, { zoom: 1.5, duration: 400 });
};
// Convert pointer coordinates to flow space
const onPaneClick = (e: React.MouseEvent) => {
const position = screenToFlowPosition({ x: e.clientX, y: e.clientY });
// add node at position
};
// Save & restore full flow state (nodes, edges, viewport)
const snapshot = toObject();v12 vs v13 Differences
| Area | @xyflow/react v12 | @xyflow/react v13 (React 19 + Zustand 5) |
| CSS & Tailwind v4 | @xyflow/react/dist/style.css | @xyflow/react/style.css (wrapped in @layer xyflow); optional @xyflow/react/xy-theme.css |
| Connection hook | useNodeConnections (preferred; useHandleConnections deprecated in v12.4+) | useNodeConnections / getNodeConnections (useHandleConnections & getHandleConnections removed) |
| Store hooks | Monolithic useStore(selector, shallow) & useStoreApi() | Split stores: useNodesStore, useEdgesStore, useViewportStore, useOptionsStore, useConnectionStore, useSelectionStore (use useShallow), plus useReactFlowStoreApi, useNode, useEdge |
| Sub-flow ordering | Parent nodes MUST precede child nodes in nodes[] | Parent-before-child ordering requirement removed |
onConnectEnd coords | Convert clientX/clientY via screenToFlowPosition | connectionState.to is already in flow coordinates (pointer has screen coords) |
fitViewOptions.padding | Fraction (0.2 = 20%) | Defaults to '5%'; unitless numbers are treated as pixels (use '20%' for percentage) |
Scale & Alternatives Heuristic
- < 100 nodes: Default
<ReactFlow />settings. - 100–500 nodes: Enable
onlyRenderVisibleElements={true}and keep custom nodes lightweight withmemo(). - 500–1,000+ nodes: Simplify node DOM, avoid subscribing nodes to full
nodes/edgesarrays, and run layout in a Web Worker. - 10k+ nodes / static / 3D: Consider WebGL graph renderers (e.g., Sigma.js) for 10k+ nodes, plain SVG/Canvas for static diagrams, or Three.js / react-three-fiber for 3D.
Reference Files
- Custom Primitives —
CSSPropertiestyping, dynamic handles (useUpdateNodeInternalspost-commit),NodeToolbar,NodeResizer,EdgeToolbar,Panel, path helpers (stepPosition),EdgeLabelRenderer,EdgeText,MarkerType, andonBeforeDelete. - Advanced Patterns & Dagre Layout — Sub-flows (
parentId,extent,expandParent),onConnectEnddrop-to-create,useNodesData+useNodeConnections,onNodesChangemiddleware, v12 vs v13 store selectors, and@dagrejs/dagreauto-layout.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

