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

react-flow-edge-overlapping

v0.1.2

Published

Overlapping (hop) edges for React Flow / @xyflow/react — draws little bridge arcs where wires cross, like a circuit diagram.

Downloads

501

Readme

react-flow-edge-overlapping

Circuit-style "hop" edges for React Flow / @xyflow/react.

When two wires cross, the edge on top draws a small bridge arc over the one underneath — just like an electrical schematic.

npm version npm downloads bundle size license


Why?

By default, React Flow edges that cross just overlap in a flat, ambiguous tangle. In schematics, dense diagrams, and circuit-style flows you usually want the wire on top to hop over the one beneath it so the routing stays readable. This package is a drop-in custom edge that does exactly that.

Features

  • Automatic hop arcs — detects crossings and draws a clean bridge over the wire underneath.
  • Smart fan-out — edges leaving the same source handle spread apart instead of stacking.
  • Deterministic layering — only the edge rendered on top draws the hop, so bumps are always visible.
  • Zero CSS — pure SVG; color and width come from the standard React Flow style prop.
  • Fully typed — ships TypeScript declarations, ESM + CJS builds.
  • Tiny & tree-shakeable — no runtime dependencies beyond your existing React Flow.

Table of contents

Install

npm install react-flow-edge-overlapping
# or
bun add react-flow-edge-overlapping
# or
pnpm add react-flow-edge-overlapping

Peer dependencies (you almost certainly already have these):

npm install @xyflow/react react react-dom

Requires @xyflow/react v12+, React 18 or 19.

Quick start

Register the edge in edgeTypes and give your edges type: "hop":

import { ReactFlow } from "@xyflow/react";
import { HopEdge } from "react-flow-edge-overlapping";
import "@xyflow/react/dist/style.css";

const edgeTypes = { hop: HopEdge };

const nodes = [
  { id: "a", position: { x: 0, y: 0 }, data: { label: "A" } },
  { id: "b", position: { x: 320, y: 80 }, data: { label: "B" } },
];

const edges = [
  {
    id: "a-b",
    source: "a",
    target: "b",
    type: "hop",
    style: { stroke: "#6366f1", strokeWidth: 2 },
  },
];

export default function App() {
  return (
    <div style={{ width: "100%", height: "100vh" }}>
      <ReactFlow nodes={nodes} edges={edges} edgeTypes={edgeTypes} />
    </div>
  );
}

Colors and stroke width come from the standard React Flow style prop on each edge, so the hop edge automatically matches whatever theme you already use.

Configuration

Global (per edge type)

Use createHopEdge(options) to build a configured component once and reuse it:

import { createHopEdge } from "react-flow-edge-overlapping";

const edgeTypes = {
  hop: createHopEdge({
    hopRadius: 8, // bridge arc radius        (default 6)
    fanStart: 20, // first sibling offset      (default 18)
    fanStep: 16, // spacing between siblings  (default 14)
    epsilon: 0.5, // intersection tolerance    (default 0.5)
  }),
};

| Option | Type | Default | Description | | ----------- | -------- | ------- | ------------------------------------------------------------ | | hopRadius | number | 6 | Radius of the bridge arc drawn where wires cross. | | fanStart | number | 18 | Horizontal offset of the first branch when edges fan out. | | fanStep | number | 14 | Spacing between successive sibling branches. | | epsilon | number | 0.5 | Tolerance for treating segments as aligned / intersecting. |

Per edge

Any option can be overridden on a single edge via edge.data:

const edges = [
  { id: "a-b", source: "a", target: "b", type: "hop", data: { hopRadius: 10 } },
];

Notes & gotchas

  • Layering matters. Only the edge rendered on top (later in the edges array) draws the hop, so the bridge is always visible above the wire underneath.
  • Recompute on drag. After dragging nodes, trigger a re-render of edges so hops recompute against the new positions — e.g. bump a value in each edge's data inside onNodeDragStop:
const onNodeDragStop = useCallback(() => {
  setEdges((eds) => eds.map((e) => ({ ...e, data: { ...e.data, _t: Date.now() } })));
}, [setEdges]);

API reference

| Export | Description | | ------------------------ | ---------------------------------------------- | | HopEdge | Default-configured edge component. | | createHopEdge(options) | Factory returning a configured edge component. | | HopEdgeOptions | Options type for createHopEdge. | | HopEdgeData | Per-edge data override type. |

These pure functions power the edge and are exported for advanced/custom routing:

buildPolyline, polylineToPath, branchXFor, getHandlePos, computeHops, plus the Pt, Hop, and DEFAULT_HOP_EDGE_OPTIONS exports.

Support

If this package saves you time, check out more React Flow templates and examples on VisualFlow — production-ready workflow builders, automation UIs, and diagram tools you can ship in days.

VisualFlow

If you'd like to support ongoing open-source work, you can also buy me a coffee:

Buy Me a Coffee

License

MIT