@realflow/react 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +153 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # @realflow/react
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@realflow/react.svg?color=cb3837&logo=npm)](https://www.npmjs.com/package/@realflow/react)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@realflow/react.svg?color=cb3837)](https://www.npmjs.com/package/@realflow/react)
5
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/olbboy/realflow/blob/main/LICENSE)
6
+ [![types](https://img.shields.io/badge/types-included-3178c6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7
+
8
+ **The fastest, most beautiful open-source library for building node-based UIs
9
+ with React.** Flow editors, workflow builders, data pipelines and node graphs —
10
+ with the features other libraries put behind a paywall built in and free:
11
+ undo/redo, auto-layout, viewport culling, typed ports, alignment guides,
12
+ AI-agent operations and real-time collaboration.
13
+
14
+ An open-source [React Flow](https://github.com/xyflow/xyflow) alternative — with
15
+ a [drop-in migration adapter](https://www.npmjs.com/package/@realflow/compat).
16
+
17
+ ![RealFlow showcase](https://raw.githubusercontent.com/olbboy/realflow/main/docs/assets/showcase-light.png)
18
+
19
+ ```bash
20
+ npm install @realflow/react
21
+ ```
22
+
23
+ > Requires React 18 or 19 (peer dependency). Ships ESM + TypeScript types.
24
+
25
+ ## Quick start
26
+
27
+ ```tsx
28
+ import { RealFlow, Background, Controls, MiniMap } from '@realflow/react';
29
+ import '@realflow/react/styles.css';
30
+
31
+ const nodes = [
32
+ { id: 'a', position: { x: 0, y: 0 }, data: { label: 'Hello' } },
33
+ { id: 'b', position: { x: 260, y: 80 }, data: { label: 'World', description: 'it just works' } },
34
+ ];
35
+ const edges = [{ id: 'e1', source: 'a', target: 'b', animated: true }];
36
+
37
+ export default function App() {
38
+ return (
39
+ <div style={{ width: '100vw', height: '100vh' }}>
40
+ <RealFlow defaultNodes={nodes} defaultEdges={edges}>
41
+ <Background />
42
+ <Controls />
43
+ <MiniMap />
44
+ </RealFlow>
45
+ </div>
46
+ );
47
+ }
48
+ ```
49
+
50
+ That's the whole app. Pan, zoom, drag, connect, box-select, delete, **undo/redo**
51
+ (`⌘Z` / `⌘⇧Z`), alignment guides and dark mode all work out of the box — no
52
+ `onNodesChange`, no `applyNodeChanges`, no state wiring.
53
+
54
+ ## Drive it imperatively
55
+
56
+ `useRealFlow()` returns an imperative API — no reducers, no change handlers:
57
+
58
+ ```tsx
59
+ import { useRealFlow } from '@realflow/react';
60
+
61
+ function Toolbar() {
62
+ const flow = useRealFlow();
63
+ return (
64
+ <>
65
+ <button onClick={() => flow.addNode({ id: crypto.randomUUID(), position: { x: 0, y: 0 }, data: { label: 'New' } })}>
66
+ Add
67
+ </button>
68
+ <button onClick={() => flow.layout('layered', { duration: 300 })}>Auto layout</button>
69
+ <button onClick={() => flow.undo()}>Undo</button>
70
+ <button onClick={() => flow.fitView({ duration: 300 })}>Fit</button>
71
+ </>
72
+ );
73
+ }
74
+ ```
75
+
76
+ ## Custom nodes
77
+
78
+ ```tsx
79
+ import { RealFlow, Handle, type NodeProps } from '@realflow/react';
80
+
81
+ function MetricNode({ data, selected }: NodeProps<{ kpi: string }>) {
82
+ return (
83
+ <div className={selected ? 'ring' : ''}>
84
+ <Handle kind="target" side="left" />
85
+ {data.kpi}
86
+ <Handle kind="source" side="right" dataType="number" maxConnections={1} />
87
+ </div>
88
+ );
89
+ }
90
+
91
+ <RealFlow nodeTypes={{ metric: MetricNode }} defaultNodes={nodes} defaultEdges={edges} />
92
+ ```
93
+
94
+ Handles are measured automatically — put them anywhere in your markup and edges
95
+ anchor exactly. Typed ports (`dataType` + `maxConnections`) reject incompatible
96
+ or full connections live while dragging.
97
+
98
+ ## What you get for free
99
+
100
+ - **⚡ Performance as architecture** — fine-grained reactivity (dragging one node
101
+ re-renders one node + its edges), zero-render pan/zoom written straight to the
102
+ DOM, spatial-hash viewport culling **on by default**, and a canvas MiniMap that
103
+ repaints 10k nodes in about a millisecond.
104
+ - **↩️ Real undo/redo** — transactional, drag-coalescing; reactive
105
+ `canUndo`/`canRedo` via `useHistory()`.
106
+ - **🧭 Built-in auto-layout** — `layered`, `tree`, `force`, `radial`, `grid` —
107
+ zero deps (no dagre, no elkjs). Async / off-thread variants included.
108
+ - **📐 Figma-style alignment guides + snapping** — on by default.
109
+ - **🎨 Beautiful by default** — light/dark theme, `colorMode="auto"`, themeable
110
+ with CSS variables (`--rf-accent`, `--rf-node-bg`, …).
111
+ - **🧩 Pro components** — `NodeResizer`, `NodeToolbar`, edge reconnection,
112
+ clipboard (`⌘C`/`⌘V`/`⌘D`/`⌘X`, id-remapped).
113
+ - **♿ Accessibility** — focusable nodes, aria roles, spatial keyboard navigation.
114
+ - **🤖 AI-ready & 🔄 collaborative** — validated JSON operations for LLM agents
115
+ and transport-agnostic real-time sync + presence (`RemoteCursors`).
116
+
117
+ ## Hooks & components
118
+
119
+ **Components:** `RealFlow`, `Background`, `MiniMap`, `Controls`, `Panel`,
120
+ `Handle`, `NodeResizer`, `NodeToolbar`, `RemoteCursors`.
121
+
122
+ **Hooks:** `useRealFlow`, `useNodes`, `useEdges`, `useViewport`, `useSelection`,
123
+ `useHistory`, `useConnection`, `useOnSelectionChange`, `useSelectionCount`,
124
+ `useFlowSelector`.
125
+
126
+ This package re-exports the entire [`@realflow/core`](https://www.npmjs.com/package/@realflow/core)
127
+ surface, so a single import serves most apps.
128
+
129
+ ## Migrating from React Flow?
130
+
131
+ [`@realflow/compat`](https://www.npmjs.com/package/@realflow/compat) is a drop-in
132
+ adapter — change your imports and an existing React Flow app runs on RealFlow's
133
+ engine (undo/redo and culling included, free):
134
+
135
+ ```diff
136
+ - import { ReactFlow, Handle, Position, useReactFlow } from '@xyflow/react';
137
+ + import { ReactFlow, Handle, Position, useReactFlow } from '@realflow/compat';
138
+ ```
139
+
140
+ ## Documentation
141
+
142
+ - [Getting started](https://github.com/olbboy/realflow/blob/main/docs/getting-started.md)
143
+ - [Custom nodes & edges](https://github.com/olbboy/realflow/blob/main/docs/custom-nodes.md)
144
+ - [Auto-layout](https://github.com/olbboy/realflow/blob/main/docs/layout.md)
145
+ - [Performance guide](https://github.com/olbboy/realflow/blob/main/docs/performance.md)
146
+ - [Tailwind / shadcn / Radix / Base UI](https://github.com/olbboy/realflow/blob/main/docs/integrations.md)
147
+ - [AI agent integration](https://github.com/olbboy/realflow/blob/main/docs/ai-integration.md)
148
+ - [Migrating from React Flow](https://github.com/olbboy/realflow/blob/main/docs/migration.md)
149
+ - [Core concepts & API](https://github.com/olbboy/realflow/blob/main/docs/api.md)
150
+
151
+ ## License
152
+
153
+ [MIT](https://github.com/olbboy/realflow/blob/main/LICENSE) © RealFlow contributors — every feature above is free, forever.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realflow/react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "The fastest, most beautiful React library for building node-based UIs. Fine-grained rendering, built-in auto-layout, undo/redo, alignment guides \u2014 free and open source.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -26,7 +26,7 @@
26
26
  "build": "tsc -p tsconfig.build.json && node ../../scripts/append-js-extensions.mjs dist && cp src/styles.css dist/styles.css"
27
27
  },
28
28
  "dependencies": {
29
- "@realflow/core": "0.2.0"
29
+ "@realflow/core": "0.2.1"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=18",