Setup

Recharts npm: How to Install Recharts and react-is the Right Way

Install Recharts from npm, yarn, pnpm or Deno, understand why react-is must match your React version and verify the package in your project.

Custom editorial artwork featuring the npm installation command in a code terminal

The quickest way to add charts to a React application is the Recharts npm package. One command pulls in the library and its type declarations, and you can start importing chart components immediately. There is one detail that trips people up, though: the react-is package.

The recommended install command

The project README recommends installing Recharts together with react-is:

npm install recharts react-is

The same packages can be added with other package managers:

# yarn
yarn add recharts react-is

# pnpm
pnpm add recharts react-is

# Deno
deno add recharts react-is

Why react-is has to match React

react-is is a small package published by the React team that lets libraries identify different kinds of React elements. Recharts uses it while walking through the children of a chart. The README is explicit that the react-is version needs to match the version of react installed in your project. If your app runs React 19 but an older react-is is resolved, element checks can behave unexpectedly and charts may fail to render children such as lines or bars.

A simple habit avoids the problem: install react-is at the same major version as React.

# check what is installed
npm ls react react-is recharts

If npm ls shows two different React versions, fix the duplication first. Multiple copies of React in one bundle cause problems far beyond charts.

TypeScript support

The npm package ships with built-in type declarations, so there is no separate @types package to install. Props such as dataKey, stroke or strokeWidth are type-checked in editors like VS Code, which makes exploring the API much faster.

Your first import

Once installed, import only the components you use. Recharts is designed around small composable pieces:

import { LineChart, Line, XAxis, YAxis, Tooltip } from "recharts";

const data = [
  { month: "Jan", visits: 400 },
  { month: "Feb", visits: 520 },
  { month: "Mar", visits: 480 },
];

export default function Visits() {
  return (
    <LineChart width={480} height={260} data={data}>
      <XAxis dataKey="month" />
      <YAxis />
      <Tooltip />
      <Line type="monotone" dataKey="visits" stroke="#5B54D6" />
    </LineChart>
  );
}

For a full walkthrough, including responsive sizing, see the Recharts React tutorial.

npm package vs GitHub source ZIP

OptionWhat you getBest for
npm packagePublished, built release with type declarationsApplications and production dashboards
GitHub ZIP (download)Raw source of the main branchReading code, testing fixes, contributing
UMD buildBrowser script exposing window.Recharts (needs React loaded first)Quick demos without a bundler

Keeping Recharts up to date

Use npm outdated to see when a newer release is available. Minor and patch updates are usually safe, while a new major version may include breaking changes — Recharts 3, for example, came with a migration guide. Commit your lockfile so every developer and your CI server install exactly the same versions.

Common install issues

  • Peer dependency warnings – usually mean react-is is missing or on a different major version than React.
  • Module not found – check that the package was added to dependencies, not installed globally.
  • Chart renders nothing – often a sizing issue rather than an install problem; see our troubleshooting guide.

Understand what the package manager installs

When npm installs Recharts, it resolves a published version of the library alongside packages required by the surrounding React environment. The package manager does not know whether a chart will be visually effective; its task is to build a dependency graph that satisfies the project’s declared constraints. This explains why an installation may finish successfully even though an application later exhibits an incompatible combination of libraries or an incorrectly configured rendering environment.

Start from a working React project and inspect its existing dependencies before adding charting packages. Read the package requirements for the release you intend to use, including any peer-dependency guidance. A peer dependency expresses an expectation about a package supplied by the application, rather than a guarantee that every compatible version has been installed. The precise requirements may change with future releases. Confirm them against the selected package version instead of treating a command copied from an old tutorial as permanently authoritative.

Make version compatibility deliberate

React, react-dom and supporting React utilities should form a coherent set. If your chosen Recharts release requires react-is, its version should align with the React version used by the application. Avoid resolving warnings by installing arbitrary versions until the terminal becomes quiet. Instead, read the peer-dependency message and identify which package declared the incompatible range. That small diagnostic habit prevents a temporary workaround from becoming an obscure production defect months later.

Version ranges deserve attention too. A caret range can allow compatible updates within the constraints of semantic versioning, while a lockfile records the exact resolved dependency graph for reproducible installations. Commit the lockfile used by the team and prefer consistent installation commands in continuous integration. When updating a dependency, review the resulting diff rather than changing several foundational packages without a clear reason. The objective is not merely a green installation log; it is an environment whose behaviour can be explained and reproduced.

Validate the first render

After installation, create one deliberately simple component: a short array of objects, a chart with an explicit height and a single series. Render it before introducing custom tooltips, animation, elaborate themes or remote data. This gives you a baseline that distinguishes package problems from application problems. If the minimal chart renders, add complexity a step at a time and check the result after each change. A small demonstrable success is a better diagnostic instrument than a sophisticated chart that fails in several possible ways.

Also check the environment in which the component runs. Browser-oriented chart libraries may require client-side rendering in applications that mix server and client components. If the chart belongs to a Next.js interface, place it at the appropriate client boundary. Verify that the container has measurable dimensions and that the values used by the plotted series are numeric. These ordinary layout and data issues are often mistaken for installation failures because they appear immediately after adding a new package.

Protect a production release

Install packages in a controlled development branch, run the available type checks and inspect representative screens at mobile and desktop widths. A dashboard is an interface, so visual regressions are production regressions even when tests pass. Confirm that labels remain readable, tooltips still work and chart colours follow the product’s design system. For organisations with an accessibility review process, include charts in that process rather than assuming graphical content needs no additional textual context.

Keep a record of the versions tested together and resist upgrading a package without reading relevant release notes. Source archives may help you inspect an implementation, but most application teams should consume the published package through their established dependency process. This separation makes it possible to investigate fixes on a branch while preserving a known-good build. The most dependable installations are simple, documented and easy for another developer to repeat without oral instructions.

Troubleshoot with evidence

If npm reports a dependency conflict, identify the exact packages and version ranges it names. If bundling fails, inspect the first meaningful error rather than the last line of a long stack trace. If a page loads but a chart is blank, measure its container and inspect the input data before reinstalling packages. These symptoms arise at different stages of development and should be addressed with different tests. Repetition of the install command is rarely a substitute for locating the failing assumption.

When sharing a reproducible example with a colleague, include the package manifest, lockfile status, React version, runtime version and minimal chart code. Describe which commands were run and what output appeared. This creates an investigation another person can actually verify. Package management should become a quiet foundation of the application, leaving the team free to focus on accurate data presentation and useful interactions rather than persistent uncertainty about its local environment.

Conclusion

A dependable Recharts setup depends on compatible versions, a reproducible dependency graph and a minimal chart that proves the rendering environment works. Resolve warnings through evidence, keep project tooling consistent and review visual behaviour after updates. Once installation is predictable, attention can return to the more important task: presenting data with accuracy and clarity.