vis-network is the core visualization engine used for drawing dynamic networks and graphs in browsers. It is framework-agnostic and provides the underlying logic for rendering nodes, edges, and physics simulations. react-graph-vis is a React component wrapper built on top of vis-network. It aims to simplify integration by exposing the library as a declarative React component, handling the lifecycle mounting and unmounting internally. While react-graph-vis offers convenience, vis-network provides direct access to the full API without an abstraction layer.
Both react-graph-vis and vis-network enable developers to build interactive network graphs, but they differ significantly in architecture. vis-network is the underlying engine, while react-graph-vis is a React-specific wrapper around it. Let's compare how they handle initialization, events, and updates.
react-graph-vis treats the graph as a standard React component.
// react-graph-vis: Declarative component
import Graph from 'react-graph-vis';
function MyGraph() {
const data = { nodes: [...], edges: [...] };
const options = { physics: { enabled: true } };
return <Graph graph={data} options={options} />;
}
vis-network requires you to create an instance manually.
ref to access the DOM container.useEffect hook.// vis-network: Imperative instance
import { Network } from 'vis-network/standalone';
import { useEffect, useRef } from 'react';
function MyGraph() {
const containerRef = useRef(null);
useEffect(() => {
const data = { nodes: [...], edges: [...] };
const options = { physics: { enabled: true } };
new Network(containerRef.current, data, options);
}, []);
return <div ref={containerRef} />;
}
react-graph-vis defines events in a props object.
// react-graph-vis: Events via props
const events = {
click: (params) => {
console.log('Node clicked', params.nodes);
}
};
<Graph graph={data} events={events} />;
vis-network attaches listeners to the network instance.
// vis-network: Events via instance
useEffect(() => {
const network = new Network(containerRef.current, data, options);
network.on('click', (params) => {
console.log('Node clicked', params.nodes);
});
return () => network.destroy(); // Cleanup
}, []);
react-graph-vis attempts to handle updates via prop changes.
graph props triggers internal updates.// react-graph-vis: Update via props
function MyGraph({ nodes }) {
const data = { nodes, edges: [] };
// Component re-renders when nodes change
return <Graph graph={data} />;
}
vis-network gives you methods to update data explicitly.
setData or manipulate datasets directly.// vis-network: Update via methods
useEffect(() => {
const network = new Network(containerRef.current, data, options);
// Update nodes later without full re-init
network.setData({ nodes: newNodes, edges: data.edges });
}, [newNodes]);
react-graph-vis depends on the maintainer updating the wrapper.
// react-graph-vis: Potential version mismatch
// You rely on the wrapper author to update vis-network deps
import Graph from 'react-graph-vis';
vis-network is the source of truth for features.
// vis-network: Direct dependency
// You control the version of vis-network directly
import { Network } from 'vis-network/standalone';
Since react-graph-vis wraps vis-network, they share the underlying rendering logic. Here are key overlaps:
options object structure for physics, styling, and layout.// Shared options structure
const options = {
nodes: { shape: 'dot' },
physics: { enabled: true }
};
nodes and edges arrays or datasets.// Shared data structure
const data = {
nodes: [{ id: 1, label: 'Node 1' }],
edges: [{ from: 1, to: 2 }]
};
// Both render to a DOM container
<div id=
Choose vis-network if you require full control over the network instance, need to access imperative methods, or want to ensure you are using the latest features without waiting for a wrapper update. It is ideal for complex applications where you need to manipulate the graph programmatically or integrate deeply with React state management. This approach requires more setup but offers better long-term stability and flexibility.
Choose react-graph-vis if you need to get a simple graph up and running quickly with minimal boilerplate. It is suitable for projects where you want declarative props to manage data and options without writing useEffect hooks for initialization. However, be aware that wrapper libraries may lag behind the core library in features or React version compatibility.

Network is a visualization to display networks and networks consisting of nodes and edges. The visualization is easy to use and supports custom shapes, styles, colors, sizes, images, and more. The network visualization works smooth on any modern browser for up to a few thousand nodes and edges. To handle a larger amount of nodes, Network has clustering support. Network uses HTML canvas for rendering.
Install via npm:
$ npm install vis-network
A basic example on loading a Network is shown below. More examples can be found in the examples directory of the project.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Network</title>
<script
type="text/javascript"
src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"
></script>
<style type="text/css">
#mynetwork {
width: 600px;
height: 400px;
border: 1px solid lightgray;
}
</style>
</head>
<body>
<div id="mynetwork"></div>
<script type="text/javascript">
// create an array with nodes
var nodes = new vis.DataSet([
{ id: 1, label: "Node 1" },
{ id: 2, label: "Node 2" },
{ id: 3, label: "Node 3" },
{ id: 4, label: "Node 4" },
{ id: 5, label: "Node 5" },
]);
// create an array with edges
var edges = new vis.DataSet([
{ from: 1, to: 3 },
{ from: 1, to: 2 },
{ from: 2, to: 4 },
{ from: 2, to: 5 },
{ from: 3, to: 3 },
]);
// create a network
var container = document.getElementById("mynetwork");
var data = {
nodes: nodes,
edges: edges,
};
var options = {};
var network = new vis.Network(container, data, options);
</script>
</body>
</html>
To build the library from source, clone the project from github
$ git clone git://github.com/visjs/vis-network.git
The source code uses the module style of node (require and module.exports) to
organize dependencies. To install all dependencies and build the library,
run npm install in the root of the project.
$ cd vis-network
$ npm install
Then, the project can be build running:
$ npm run build
To test the library, install the project dependencies once:
$ npm install
Then run the tests:
$ npm run test
Contributions to the vis.js library are very welcome! We can't do this alone!
Thank you to all our backers! π
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
Copyright (C) 2010-2018 Almende B.V. and Contributors Copyright (c) 2018-2021 Vis.js contributors
Vis.js is dual licensed under both
and
Vis.js may be distributed under either license.