React Flow,用于使用 React 或 Svelte 构建基于节点的 UI 的开源库。
React Flow, open source libraries for node-based UIs with React or Svelte

原始链接: https://github.com/xyflow/xyflow

xyflow 仓库包含 React Flow 和 Svelte Flow,它们是用于构建基于节点的 UI 的库。如果您在个人项目中使用它们,欢迎提供错误报告和项目截图等贡献! 商业使用这些库的组织,鼓励通过 React Flow Pro 或 Github Sponsors 赞助开发,以确保在 MIT 许可下持续维护。 入门很容易 – 探索每个库的“学习”部分。基本用法包括通过 npm 安装 (`@xyflow/react` 或 `@xyflow/svelte`) 并导入必要的组件。该仓库使用 changesets 来简化包发布。 如有任何支持、合作机会或一般咨询,可以通过联系表单或 Discord 服务器联系 xyflow 团队。React Flow 和 Svelte Flow 都是开源的,并采用 MIT 许可。

## React Flow:流行的基于节点的UI库 React Flow 是一个用于使用 React 和最近的 Svelte 构建基于节点的用户界面的开源库。 它的吸引力日益增强,这体现在 Supabase 的可视化模式设计器和各种 AI 工具可视化等项目中的应用。 用户称赞它的灵活性、易用性(节点只是 React/Svelte 组件)和积极的开发。 Svelte 5 版本现已可用,并且示例丰富。 虽然总体评价良好,但一些用户希望支持 React Native,一位开发者分享了一个受 React Flow 启发的原型库 (@lincle)。 讨论还涉及 React 的复杂性和重新渲染问题,并与 Svelte 的方法进行了对比。 该库的盈利策略——对未付费的商业用途进行“随心所欲付费”模式和公开羞辱——引发了争论,并提出了双重许可方法的建议。 许多用户分享了使用 React Flow 构建的个人项目,展示了它在 AI 可视化、IaC 构建器和桌面 UI 创建等任务中的多功能性。
相关文章

原文

xyflow-header xyflow-header-dark


The xyflow repository is the home of four packages:

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.

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 and use the libraries you can see it here:

React Flow basic usage
npm install @xyflow/react
import { useCallback } from 'react';
import {
ReactFlow,
MiniMap,
Controls,
Background,
useNodesState,
useEdgesState,
addEdge,
} from '@xyflow/react';

import '@xyflow/react/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;
Svelte Flow basic usage
npm install @xyflow/svelte
<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>

For releasing packages we are using changesets in combination with the changeset Github action. The rough idea is:

  1. create PRs for new features, updates and fixes (with a changeset if relevant for changelog)
  2. merge into main
  3. changset creates a PR that bumps all packages based on the changesets
  4. merge changeset PR if you want to release to Github and npm

React Flow and Svelte Flow are maintained by the xyflow team. 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.

React Flow and Svelte Flow are MIT licensed.

联系我们 contact @ memedata.com