Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To add an interactive pivot table to a React app, install react-pivottable, pass it data in a supported tabular format, and save every layout change through its onChange callback. The component is controlled: React state holds the current pivot configuration and is passed back to the component on each render. Charts are optional; start with a table renderer unless users need chart output.

Build a basic pivot table with react-pivottable

The Plotly react-pivottable project is a React port of PivotTable.js. It lets users explore and summarize data in a table or chart through a two-dimensional drag-and-drop interface. Its documented table-only setup is a useful starting point when users need to move fields themselves.

1. Install the package

npm install --save react-pivottable react react-dom

If your application already includes React and React DOM, retain the versions required by your app and verify compatibility with the package rather than installing duplicate versions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Import the component and stylesheet

Import PivotTableUI from the package and include its CSS. The stylesheet supplies the component’s presentation; without it, the interface may not appear as intended.

import PivotTableUI from 'react-pivottable/PivotTableUI';
import 'react-pivottable/pivottable.css';

3. Supply data in a supported format

The project README’s example uses an array of arrays with a header row. Before passing production records, check the project’s input-format documentation and adapt your data to a format it supports. Do not assume that an arbitrary API response or array of objects can be passed unchanged.

4. Keep the pivot configuration in React state

PivotTableUI is designed to receive its configuration from the application. Its onChange callback reports changes; save the new configuration in state, then spread that state back into the component. A simplified class-component pattern is:

import React from 'react';
import PivotTableUI from 'react-pivottable/PivotTableUI';
import 'react-pivottable/pivottable.css';

class SalesPivot extends React.Component {
  state = { data: this.props.data };

  render() {
    return (
      <PivotTableUI
        data={this.state.data}
        onChange={s => this.setState(s)}
        {...this.state}
      />
    );
  }
}

Here, this.props.data should already be in a supported input format. The important pattern is that onChange stores the changed settings and {'{...this.state}'} feeds them back on the next render. If the application uses hooks or a state-management library, use the same data flow: update the stored configuration in response to onChange, then pass the current configuration as props.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add charts only when users need them

Chart rendering is an optional extension, not a prerequisite for a pivot table. The README demonstrates adding Plotly by installing react-plotly.js and plotly.js, importing TableRenderers, creating Plotly renderers with createPlotlyRenderers(Plot), and passing the combined renderers to PivotTableUI. The Plotly React component is supplied to the renderer factory.

This adds dependencies and a build decision. The project documentation flags Plotly bundling considerations for webpack and also describes an external window.Plotly approach. Consult its chart integration instructions for the setup that matches your build system; do not add the chart stack if a table is sufficient.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose a component based on the workflow

The right option depends on whether people need to rearrange fields, how complex the aggregation is, and whether analysis must run on the server. The available documentation gives feature examples, not a complete current compatibility or pricing matrix, so verify package versions, React compatibility, build requirements, and licensing before adopting a component.

Approach Documented capabilities Best fit Important qualification
react-pivottable Drag-and-drop field exploration, table rendering, and optional Plotly chart renderers Users who need to build or change a pivot layout interactively Chart rendering adds dependencies and bundling considerations; confirm supported input formats in the project documentation.
React Table v6 grouping pivotBy, custom aggregation functions, sorting of pivoted columns, and filtering Applications that need grouped rows and aggregates within a table framework, but not a dedicated drag-and-drop pivot interface The cited documentation is for v6. Confirm the intended package version before using it for a current project.
Syncfusion React PivotView Field reorganization, member filtering, hierarchy drilling, and configurable server-side aggregation, filtering, sorting, and grouping Broader analysis workflows, especially when server-side processing or hierarchy features matter Check current compatibility and licensing or pricing directly with the React PivotView overview.
DevExpress React PivotGrid Sorting, header filtering, and XLSX export in its getting-started documentation Applications that need a fuller PivotGrid workflow, including spreadsheet export Check current compatibility and licensing or pricing directly with the React PivotGrid getting-started documentation.

React Table’s documented v6 features are described in its API overview. They provide grouping and aggregation inside a table framework, not the same interaction model as a dedicated pivot UI.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use these checks before committing to an implementation

  • Field arrangement: Decide whether users must drag fields between rows, columns, and values, or whether fixed grouping controls are enough.
  • Analysis depth: Check whether ordinary aggregation meets the need or users require hierarchy drilling, member filtering, and more elaborate analysis.
  • Processing location: Establish whether data can be summarized in the browser or aggregation, filtering, sorting, and grouping must be configurable on the server.
  • Output: Identify whether a table is enough or the application also needs charts or XLSX export.
  • Technical fit: Verify React version compatibility, supported input shape, dependencies, and build-system requirements against current project documentation.
  • Commercial terms: Review current licensing and pricing directly for any fuller PivotGrid product before choosing it.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.