npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tisoap/react-flow-smart-edge

v4.13.1

Published

Custom React Flow Edge that never intersects with other nodes

Readme

React Flow Smart Edge

Smart edges for React Flow that route around your nodes instead of straight through them.

Drop-in custom edges that use grid-based A* pathfinding to find a clean path between nodes, plus floating endpoints, draggable waypoints, and circuit-style hops over crossing wires.

npm version npm downloads tests Storybook Chromatic License: MIT TypeScript

Smart Edge

Why?

React Flow's built-in edges draw a direct line from source to target, which often means edges cut straight across your nodes. React Flow Smart Edge computes a path that goes around them, so your graphs stay readable even as they grow and as nodes move.

It's a tiny, dependency-light library (just @xyflow/react as a peer) that ships ready-to-use edge components and a low-level API for building your own.

Features

  • Grid-based A* / jump-point pathfinding finds a path that never crosses your nodes.
  • Five edge styles: smart equivalents of every React Flow edge (bezier, straight, step, smooth-step, and simple-bezier).
  • Step edges can draw a small bridge arc where they cross each other, so intersections read cleanly. (new!)
  • Floating edges connect to the nearest node border instead of a fixed handle.
  • Editable waypoints let you drag control points to reshape a route; each segment still avoids nodes.
  • Checkpoints route through fixed points without the editing UI.
  • Avoid areas keep edges clear of arbitrary regions (e.g. labels), not just nodes.
  • Subflow aware routing works correctly inside React Flow groups/subflows.
  • Web Worker batch routing keeps large graphs responsive by routing edges off the main thread. (new!)
  • If no path is found, the edge drops back to the native React Flow edge.
  • Swap the pathfinding or SVG drawing functions, or build custom edges with getSmartEdge.
  • Written in strict TypeScript, with browser-based interaction tests.

Install

npm install @tisoap/react-flow-smart-edge

Requires React Flow v12+ (@xyflow/react).

Quick start

import { ReactFlow } from "@xyflow/react";
import { SmartBezierEdge } from "@tisoap/react-flow-smart-edge";
import "@xyflow/react/dist/style.css";

const nodes = [
  { id: "1", data: { label: "Node 1" }, position: { x: 300, y: 100 } },
  { id: "2", data: { label: "Node 2" }, position: { x: 300, y: 200 } },
];

const edges = [{ id: "e21", source: "2", target: "1", type: "smart" }];

const edgeTypes = { smart: SmartBezierEdge };

export function Graph() {
  return (
    <ReactFlow
      defaultNodes={nodes}
      defaultEdges={edges}
      edgeTypes={edgeTypes}
      fitView
    />
  );
}

Edge components

| Export | React Flow equivalent | | ----------------------- | ------------------------------------------------------------------------------------ | | SmartBezierEdge | BezierEdge | | SmartStraightEdge | StraightEdge | | SmartStepEdge | StepEdge | | SmartSmoothStepEdge | SmoothStepEdge | | SmartSimpleBezierEdge | SimpleBezierEdge | | SmartFloatingEdge | Floating edges example | | SmartEditableEdge | Editable edge example | | SmartCheckpointEdge | No equivalent |

Configure any preset with createSmartEdge, or build custom edges with getSmartEdge:

import { createSmartEdge } from "@tisoap/react-flow-smart-edge";

const edgeTypes = {
  // finer routing grid:
  fineStep: createSmartEdge("step", { gridRatio: 5 }),
};

Circuit-style hops

Give the step variants the hops option and crossing wires bridge over each other like a schematic. The edge on top draws a small arc over the one beneath:

import { createSmartEdge } from "@tisoap/react-flow-smart-edge";

const edgeTypes = {
  hop: createSmartEdge("step", { hops: true }),
  // or smooth-step with rounded corners + bridges:
  smoothHop: createSmartEdge("smoothstep", { hops: { borderRadius: 8 } }),
};

See the hops docs for tuning and a live demo.

Web Worker batch routing

For large graphs, route every edge together on a background Web Worker so pathfinding stays off the main thread and the canvas stays responsive. Wrap your flow in SmartEdgeBatchRoutingProvider and read each edge's path with useSmartEdgeRoute:

import {
  ReactFlow,
  ReactFlowProvider,
  BaseEdge,
  BezierEdge,
} from "@xyflow/react";
import {
  SmartEdgeBatchRoutingProvider,
  useSmartEdgeRoute,
} from "@tisoap/react-flow-smart-edge";

function WorkerEdge(props) {
  const routed = useSmartEdgeRoute(props);
  if (!routed) return <BezierEdge {...props} />;
  return (
    <BaseEdge
      id={props.id}
      path={routed.svgPathString}
      markerEnd={props.markerEnd}
    />
  );
}

const edgeTypes = { worker: WorkerEdge };

function Flow({ nodes, edges }) {
  return (
    <ReactFlowProvider>
      <SmartEdgeBatchRoutingProvider
        nodes={nodes}
        options={{ preset: "bezier" }}
      >
        <ReactFlow nodes={nodes} edges={edges} edgeTypes={edgeTypes} />
      </SmartEdgeBatchRoutingProvider>
    </ReactFlowProvider>
  );
}

It is opt-in and additive: the default edge components are unchanged, and the provider falls back to main-thread routing when Web Workers are unavailable. See the Web Worker batch routing docs.

Documentation

Full documentation: tisoap.github.io/react-flow-smart-edge/docs

Guides, the full API reference, and live interactive demos for every feature.

Interactive Storybook examples are also published on Chromatic.

Support

ko-fi

GitHub Sponsors

Development

npm ci
npm run storybook    # demos + tests (port 6006)
npm run docs         # Docusaurus dev server → http://localhost:3000/docs
npm run check        # lint, types, spellcheck
npm run test         # Storybook interaction tests
npm run build-docs   # static docs site → website/build

License

MIT