How to Install Nivo charts with npm in a React Project?
Learn how to install Nivo charts with npm, add @nivo/core and chart packages, prepare data and render your first responsive chart in React.
Read guide
Nivo charts library brings a large set of ready-made data visualisation components to React. Built on top of D3 and maintained as an open-source project, it lets developers render bar, line, pie, heatmap, sankey and many other charts by passing data and props instead of writing low-level drawing code. This overview explains how the library is organised and when it is the right choice.
Nivo is a collection of React components that turn structured data into charts. D3 modules handle the mathematics behind scales, shapes, layouts and colour schemes, while React takes care of rendering and updates. The result is a declarative API where each chart behaves like any other component in your application.
The project was created by Raphaël Benitte, known on GitHub as plouc, and is released under the MIT licence. It is developed in the open on GitHub, with documentation and live demos published on the nivo.rocks website.
Nivo is split into many small npm packages rather than one large bundle. Each chart type has its own package, and a set of shared packages provides common building blocks. Installing only the charts you render keeps dependency lists focused and makes it clear which parts of the library a project relies on.
| Package type | Examples | Purpose |
|---|---|---|
| Foundation | @nivo/core | Theming, containers, motion and shared utilities |
| Chart packages | @nivo/bar, @nivo/line, @nivo/pie, @nivo/sankey | Individual chart components |
| Supporting packages | @nivo/axes, @nivo/legends, @nivo/tooltip, @nivo/colors | Axes, legends, tooltips and colour handling used by charts |
Supporting packages are pulled in automatically as dependencies of chart packages, so most projects only list @nivo/core plus the chart packages they need in package.json.
Breadth is one of the main reasons developers choose Nivo. Beyond everyday bar, line and pie charts, the library includes specialised visualisations that are often missing from smaller chart libraries. That range means a single dashboard can mix very different charts while keeping a consistent API and visual style.
Most Nivo charts render SVG by default, which keeps every bar, slice and point inspectable in browser developer tools and easy to style. Many charts also ship a Canvas variant, for example BarCanvas or ScatterPlotCanvas, which paints onto a single element and handles large datasets more comfortably.
A few components, such as the treemap, also offer an HTML version. Choosing between these renderers is usually a trade-off between styling flexibility and drawing performance, and switching is mostly a matter of importing a different component with nearly identical props.
Every chart is available in a fixed-size form, where you pass width and height, and in a responsive form such as ResponsiveLine. The responsive wrapper measures its parent element and redraws the chart whenever that element changes size, which suits fluid dashboard grids.
The important rule is that the parent must have a measurable height. A wrapper with no height gives the chart nothing to fill, which is the most common reason a first chart appears blank. Setting a fixed height or using a layout that defines one solves the issue immediately.
Visual styling is controlled through a few consistent props. The colors prop accepts named schemes, custom arrays or functions, while the theme prop controls fonts, axis ticks, grid lines, legends, labels and tooltip containers. Because the theme structure is shared across charts, one theme object can style an entire dashboard.
Animation is powered by react-spring. The animate prop switches motion on or off, and motionConfig accepts presets such as gentle or wobbly, or a custom spring configuration, which controls how charts transition when data changes.
Each chart expects data in a shape that matches its purpose. Learning these shapes early saves time, because most setup errors come from passing data in the wrong structure rather than from incorrect props.
| Chart | Expected data shape |
|---|---|
| Bar | Array of objects, with indexBy naming the category key and keys listing value fields |
| Line | Array of series, each with an id and a data array of x and y points |
| Pie | Array of objects with id, label and value |
| Calendar | Array of day and value pairs, plus from and to date props |
| Treemap and Sunburst | A single root object with nested children |
Nivo works best in React projects that need a variety of polished charts without building each one from primitives. Teams who value consistent styling, built-in interactivity and good defaults tend to get productive quickly, especially for analytics dashboards and reporting screens.
Projects that need extremely custom visuals may prefer working with D3 directly, and very small widgets might not justify extra dependencies. For most dashboard work, though, the balance between flexibility and convenience is a strong argument in its favour.
Nivo is released under the MIT licence, which permits commercial use. Check the licence file in the repository for the exact wording before shipping.
No. D3 runs behind the scenes, and charts are configured through React props. D3 knowledge only becomes useful when writing custom layers or advanced formatting.
Yes. Nivo charts are regular React components, so they sit comfortably inside layouts built with any component library or CSS approach.
Nivo charts library offers React developers a wide catalogue of D3-powered charts, a modular package structure, SVG and Canvas rendering and a consistent theming system. Understanding its packages, data shapes and responsive sizing rule makes the first chart quick to build.
From there, the documentation site and examples help you grow from a single bar chart into complete dashboards. Explore the Nivo charts examples or follow the npm installation walkthrough to continue.