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 🙏

© 2025 – Pkg Stats / Ryan Hefner

flux-node

v0.1.0

Published

A flexible, type-safe, and interactive node-based editor library built with React, TypeScript, and modern design principles.

Readme

FluxNode

A powerful React TypeScript library for creating interactive flow diagrams with draggable nodes, connectable edges, and advanced features like panning, zooming, and a minimap.

Features

  • 🎯 Interactive Nodes - Drag and drop nodes with smooth interactions
  • 🔗 Connectable Edges - Connect nodes with bezier curve edges
  • 🔍 Pan & Zoom - Navigate large diagrams with mouse controls
  • 🗺️ Mini Map - Overview and quick navigation of the entire diagram
  • 📱 Responsive - Works on different screen sizes
  • 🎨 Customizable - Style nodes and edges to fit your needs
  • Performance - Optimized for large diagrams with many nodes
  • 🔧 TypeScript - Full type safety and IntelliSense support

Installation

npm install flux-node

Basic Usage

import React, { useState, useCallback } from 'react';
import FluxNode, { 
  Node, 
  Edge, 
  NodeChange, 
  EdgeChange, 
  Connection,
  applyNodeChanges, 
  applyEdgeChanges, 
  addEdge 
} from 'flux-node';

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

const initialEdges: Edge[] = [];

function App() {
  const [nodes, setNodes] = useState<Node[]>(initialNodes);
  const [edges, setEdges] = useState<Edge[]>(initialEdges);

  const onNodesChange = useCallback(
    (changes: NodeChange[]) => setNodes((nds) => applyNodeChanges(changes, nds)),
    []
  );

  const onEdgesChange = useCallback(
    (changes: EdgeChange[]) => setEdges((eds) => applyEdgeChanges(changes, eds)),
    []
  );

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

  return (
    <div style={{ width: '100%', height: '500px' }}>
      <FluxNode
        nodes={nodes}
        edges={edges}
        onNodesChange={onNodesChange}
        onEdgesChange={onEdgesChange}
        onConnect={onConnect}
        fitView
      />
    </div>
  );
}

export default App;

API Reference

FluxNode Component Props

| Prop | Type | Description | |------|------|-------------| | nodes | Node[] | Array of nodes to display | | edges | Edge[] | Array of edges connecting nodes | | onNodesChange | (changes: NodeChange[]) => void | Callback for node changes (position, removal, etc.) | | onEdgesChange | (changes: EdgeChange[]) => void | Callback for edge changes (removal, selection, etc.) | | onConnect | (params: Connection) => void | Callback when nodes are connected | | fitView? | boolean | Whether to fit all nodes in view on mount |

Types

Node

interface Node {
  id: string;
  position: Position;
  data: {
    label: string;
  };
  type?: string;
}

Edge

interface Edge {
  id: string;
  source: string;
  target: string;
  type?: string;
}

Position

interface Position {
  x: number;
  y: number;
}

Connection

interface Connection {
  source: string;
  target: string;
  sourceHandle?: string;
  targetHandle?: string;
}

Utility Functions

applyNodeChanges(changes: NodeChange[], nodes: Node[]): Node[]

Applies an array of node changes to the nodes array. Handles position updates, removals, and other node modifications.

applyEdgeChanges(changes: EdgeChange[], edges: Edge[]): Edge[]

Applies an array of edge changes to the edges array. Handles edge removals and other edge modifications.

addEdge(connection: Connection, edges: Edge[]): Edge[]

Creates a new edge from a connection and adds it to the edges array. Prevents duplicate edges.

Controls

  • Pan: Click and drag on empty space to pan around the diagram
  • Zoom: Use mouse wheel to zoom in and out
  • Move Nodes: Click and drag nodes to reposition them
  • Connect Nodes: Click and drag from a node's right handle to another node's left handle
  • Mini Map: Click on the mini map to quickly navigate to different areas

Styling

The component uses inline styles for maximum compatibility. You can customize the appearance by modifying the component or extending it with your own styling system.

Example

Check out the complete example in the example/App.tsx file. This shows a full implementation with:

  • 3 pre-positioned nodes
  • 1 initial connection
  • Interactive controls overlay
  • Full-screen layout
  • All FluxNode features enabled

The example demonstrates:

  • Node dragging and positioning
  • Edge creation by connecting handles
  • Pan and zoom functionality
  • Minimap navigation
  • State management with React hooks

Development

# Install dependencies
npm install

# Build the library
npm run build

# Watch mode for development
npm run dev

License

MIT