Installation
Recharts is available as an npm package and can be installed using your preferred package manager.Package manager installation
The
react-is package version should match your installed react version.Peer dependencies
Recharts requires the following peer dependencies to be installed in your project:
If you don’t already have React installed, you can install all dependencies together:
UMD build
For non-module environments, Recharts is also available as a UMD build via unpkg CDN. This is useful for quick prototyping or adding charts to existing HTML pages.Include via script tags
Add the following script tags to your HTML file:Access the library
Once the scripts are loaded, Recharts will be available on the globalwindow object:
For production use, we recommend using a module bundler (webpack, Vite, etc.) with the npm package instead of the UMD build.
TypeScript support
Recharts includes comprehensive TypeScript type definitions out of the box. No additional@types package is needed.
Bundler configuration
Recharts is marked as side-effect-free in itspackage.json, which enables tree-shaking in modern bundlers. This means you only bundle the components you actually use.
Webpack
No special configuration needed. Tree-shaking works automatically in production mode.Vite
No special configuration needed. Vite handles tree-shaking by default.Next.js
Recharts works out of the box with Next.js App Router and Pages Router:When using Next.js App Router, remember to add
'use client' directive since Recharts is a client-side library.Verify installation
To verify that Recharts is installed correctly, create a simple test file:Next steps
Quick start
Learn how to create your first chart with a step-by-step tutorial