Installation
Install the package with your favorite package manager:
- npm
- yarn
- pnpm
- bun
npm install d3-graph-react
yarn add d3-graph-react
pnpm add d3-graph-react
bun add d3-graph-react
All D3 dependencies (d3-force, d3-zoom, d3-drag, d3-selection) are bundled — you don't
need to install D3 yourself.
Requirements
| Requirement | Version |
|---|---|
react | ^18.2 |
react-dom | ^18.2 |
TypeScript is fully supported out of the box — type definitions ship with the package, no
@types/* install needed.
Verify the setup
Import the component anywhere in your app:
import { Graph } from "d3-graph-react";
If that compiles, you're ready to build your first graph — head over to the Quick Start.