A small Next.js sample showcasing how to integrate the Syncfusion React Pivot Table (PivotView) component with the Next.js App Router. This repo demonstrates a client-side app/page.tsx usage, sample datasource and theme imports so you can run the demo locally in minutes. ๐
- What: Example Next.js app that integrates the Syncfusion React Pivot Table (
@syncfusion/ej2-react-pivotview). - Why: Shows how to use Syncfusion interactive components with the Next.js App Router (client components + CSS imports).
- Who: Frontend developers building data-visualization dashboards using React + Next.js.
| Feature | Description | Benefit |
|---|---|---|
| ๐ฏ Field List Interface | Dynamically add, remove, and rearrange data fields at runtime | Empowers end-users to customize reports without code modifications |
| ๐ Flexible Data Binding | Supports relational data binding with hierarchical structures | Handle complex multi-dimensional business data |
| ๐งฎ Calculated Fields | Create custom formulas combining multiple data fields | Advanced data analysis and business metric computation |
| ๐ฑ Data Formatting | Display values in currency, percentages, and custom formats | Professional presentation of numerical data |
| Sort by multiple fields with ascending/descending control | Enhanced data exploration and trend analysis | |
| ๐ Advanced Filtering | Filter by single or multiple criteria across all dimensions | Focused data analysis and drill-down exploration |
| ๐ฑ Responsive Design | Adapts seamlessly to desktop, tablet, and mobile screens | Universal accessibility across all devices |
| ๐ค Export Functionality | Export pivot table data to Excel and PDF formats | Generate shareable reports and archives |
| ๐จ Theme Support | Multiple Tailwind and Bootstrap themes available | Consistent branding and visual customization |
| โก Performance Optimized | Efficient rendering with virtual scrolling | Handle large datasets without performance degradation |
- Ready-to-run demo with sample
pivotData. - Uses Syncfusion module injection (
CalculatedField,FieldList). - Shows theme / CSS imports to
app/globals.cssfor consistent styling.
- Node.js 18 LTS or later
- npm (or yarn)
Clone, install and run the app locally:
git clone https://github.com/SyncfusionExamples/syncfusion-react-pivotview-component-in-nextjs
cd syncfusion-react-pivotview-component-in-nextjs
npm install
npm run devOpen http://localhost:3000 to view the running sample.
app/datasource.tsxโ samplepivotDataused by the demo.app/page.tsxโ client component mountingPivotViewComponentand injecting services.app/globals.cssโ recommended place to add Syncfusion theme CSS imports.
- Install the Syncfusion PivotView package:
npm install @syncfusion/ej2-react-pivotview --save- Import Syncfusion theme CSS into
app/globals.css(example Tailwind3 theme imports):
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-lists/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-calendars/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-react-pivotview/styles/tailwind3.css';
/* add other component CSS as needed */- Make
app/page.tsxa client component and mountPivotViewComponent:
'use client'
import { CalculatedField, FieldList, Inject, PivotViewComponent } from '@syncfusion/ej2-react-pivotview';
import { DataSourceSettingsModel } from '@syncfusion/ej2-pivotview/src/model/datasourcesettings-model';
import { pivotData } from './datasource';
export default function Home() {
const dataSourceSettings: DataSourceSettingsModel = {
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
dataSource: pivotData as any[],
expandAll: false,
filters: [],
drilledMembers: [{ name: 'Country', items: ['Germany'] }],
formatSettings: [{ name: 'Amount', format: 'C0' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }]
};
return (
<>
<h2>Syncfusion React Pivot Table Component</h2>
<PivotViewComponent id='PivotView' height={350} dataSourceSettings={dataSourceSettings} allowCalculatedField={true} showFieldList={true}><Inject services={[CalculatedField, FieldList]} />
</PivotViewComponent>
</>
)
}- Provide sample
pivotDatainapp/datasource.tsx(array of objects) โ the demo ships with this file.
- Theme: Swap the Tailwind3 CSS imports to a different Syncfusion theme file if you prefer (e.g.,
fabric.css,material.css). - Localization: Use Syncfusion localization utilities if needed.
- Lazy-loading: Consider dynamic imports for PivotView if server-side rendering is used elsewhere.
app/datasource.tsxโ sample dataapp/page.tsxโ demo page (client component)app/globals.cssโ place to import Syncfusion themesnext.config.js,package.json,tsconfig.jsonโ project configs
- If components donโt style correctly, ensure the theme CSS is imported into
app/globals.cssand there are no conflicting global rules. - If interactive features fail, verify
app/page.tsxincludes'use client'at the top.
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the Syncfusion Community License. See the Syncfusion License for details.
- ๐ Official Documentation: Syncfusion React PivotView
- ๐ฌ Video Tutorials: Syncfusion YouTube Channel
- ๐ฌ Support Forum: Syncfusion Support
- ๐ Report Issues: GitHub Issues
- ๐ง Contact Us: support@syncfusion.com
- ๐ Syncfusion React Components
- ๐ Syncfusion Community
- ๐ฏ Demo Sample
- โ Use virtual scrolling for large datasets (1000+ rows)
- โ Enable lazy loading for remote data sources
- โ Optimize format settings to reduce rendering overhead
- โ Use filter and drill-down to reduce data volume displayed
- โ Consider server-side aggregation for very large datasets