React Flow

高度可定制的库,用于构建基于节点的交互式 UI、编辑器、流程图和图表。「Highly customizable library for building interactive node-based UIs, editors, flow charts and diagrams」

Github星跟蹤圖

xyflow-header
xyflow-header-dark

GitHub License MIT
npm downloads
npm downloads

Powerful open source libraries for building node-based UIs with React or Svelte. Ready out-of-the-box and infinitely customizable.

React Flow · Svelte Flow · React Flow Pro · Discord


The xyflow mono repo

The xyflow repository is the home of four packages:

We just moved repositories from the @wbkd org to this one. React Flow v11 will remain on the v11 branch. When we have a stable v12, the package name of React Flow will change from reactflow to @xyflow/react.

Commercial Usage

Are you using React Flow or Svelte Flow for a personal project? Great! No sponsorship needed, you can support us by reporting any bugs you find, sending us screenshots of your projects, and starring us on Github 🌟

Are you using React Flow or Svelte Flow at your organization and making money from it? Awesome! We rely on your support to keep our libraries developed and maintained under an MIT License, just how we like it. For React Flow you can do that on the React Flow Pro website and for both of our libraries you can do it through Github Sponsors.

Getting Started

The best way to get started is to check out the React Flow or Svelte Flow learn section. However if you want to get a sneak peek of how to install the and use the libraries you can see it here:

Installation

npm install reactflow

Basic usage

import { useCallback } from 'react';
import ReactFlow, {
MiniMap,
Controls,
Background,
useNodesState,
useEdgesState,
addEdge,
} from 'reactflow';

import 'reactflow/dist/style.css';

const initialNodes = [
{ id: '1', position: { x: 0, y: 0 }, data: { label: '1' } },
{ id: '2', position: { x: 0, y: 100 }, data: { label: '2' } },
];

const initialEdges = [{ id: 'e1-2', source: '1', target: '2' }];

function Flow() {
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);

const onConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), [setEdges]);

return (
  <ReactFlow
    nodes={nodes}
    edges={edges}
    onNodesChange={onNodesChange}
    onEdgesChange={onEdgesChange}
    onConnect={onConnect}
  >
    <MiniMap />
    <Controls />
    <Background />
  </ReactFlow>
);
}

export default Flow;

Installation

npm install @xyflow/svelte

Basic usage

<script lang="ts">
import { writable } from 'svelte/store';
import {
  SvelteFlow,
  Controls,
  Background,
  BackgroundVariant,
  MiniMap,
} from '@xyflow/svelte';

import '@xyflow/svelte/dist/style.css'

const nodes = writable([
  {
    id: '1',
    type: 'input',
    data: { label: 'Input Node' },
    position: { x: 0, y: 0 }
  },
  {
    id: '2',
    type: 'custom',
    data: { label: 'Node' },
    position: { x: 0, y: 150 }
  }
]);

const edges = writable([
  {
    id: '1-2',
    type: 'default',
    source: '1',
    target: '2',
    label: 'Edge Text'
  }
]);
</script>

<SvelteFlow
{nodes}
{edges}
fitView
on:nodeclick={(event) => console.log('on node click', event)}
>
<Controls />
<Background variant={BackgroundVariant.Dots} />
<MiniMap />
</SvelteFlow>

The xyflow team

React Flow and Svelte Flow are maintained by the team behind xyflow. If you need help or want to talk to us about a collaboration, reach out through our contact form or by joining our Discord Server.

License

React Flow and Svelte Flow are MIT licensed.

主要指標

概覽
名稱與所有者xyflow/xyflow
主編程語言TypeScript
編程語言JavaScript (語言數: 4)
平台Linux, Mac, Windows
許可證MIT License
所有者活动
創建於2019-07-15 14:47:30
推送於2025-04-17 16:18:37
最后一次提交
發布數627
最新版本名稱@xyflow/system@0.0.57 (發布於 2025-04-17 15:16:09)
第一版名稱1.3.0 (發布於 2020-05-11 13:24:57)
用户参与
星數29k
關注者數128
派生數1.9k
提交數5.3k
已啟用問題?
問題數2175
打開的問題數82
拉請求數1326
打開的拉請求數18
關閉的拉請求數288
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?