react-force-graph wraps the force-graph suite as React components for 2D canvas, 3D WebGL, VR, and AR graph layouts. It uses d3-force-3d physics with rich interaction props.
Overview
react-force-graph publishes four related npm packages—2D, 3D, VR, and AR—that share parallel APIs for visualizing networks as force-directed layouts. Each accepts a graphData object with nodes and links, then iterates positions using a physics simulation while rendering with HTML canvas, Three.js, A-Frame, or AR.js as appropriate.
Common capabilities include zoom and pan, draggable nodes, hover and click handlers, customizable node and link colors, labels, widths, curvatures, and dynamic data updates. Two-dimensional mode allows custom canvas drawing callbacks for nodes and links; three-dimensional modes support custom Three.js objects, post-processing effects, and camera controls such as fit-to-canvas or automatic orbit.
The suite builds on d3-force-3d for layout forces and exposes extensive props for styling, visibility accessors, collision behavior, DAG tree modes, directional particles on links, and highlight selection patterns. VR and AR variants add stereoscopic navigation and marker-tracked placement options with configurable scale and offset.
Consumers install the specific package they need plus its peer dependencies, or load bundles via script tags in simpler setups. Example galleries demonstrate arrows, particles, text nodes, images, expandable trees, and large graphs.
Key features
- 2D, 3D, VR, and AR graph packages
- Force-directed d3-force-3d layout
- Zoom, pan, drag interactions
- Custom node and link styling hooks
- Dynamic graph data updates
- Click and hover event handlers
- DAG and tree layout modes
- Canvas or WebGL rendering paths
Use cases
- Network relationship exploration
- Knowledge graph visualization
- VR or AR graph demos
- Interactive dependency diagrams