AG Grid React Tutorial: Build a Fast React Data Grid (with Sorting, Filtering, Pagination, Editing)
If your app needs more than a “cute little table,” you’re in React data grid territory. And when you need
performance, a rich feature set, and a surprisingly mature API, AG Grid React
is often the first stop. This guide walks through AG Grid installation, a clean AG Grid React setup,
and the core features people actually search for: AG Grid filtering sorting, AG Grid pagination, and AG Grid cell editing.
The goal: an interactive table React users won’t hate—one that loads quickly, supports real workflows, and doesn’t
crumble the moment the dataset grows. Along the way, you’ll get a practical AG Grid React example that you can paste into a project and adapt.
Note on methodology: I can’t run a live Google crawl from this environment, so the “TOP-10” insights below are based on common patterns in
high-ranking англоязычные pages (official docs, popular tutorials, GitHub examples, and developer blogs), plus the provided reference:
Building Advanced Data Tables with AG Grid in React.
That’s still enough to model what ranks: intent match, complete setup steps, and demonstrable feature coverage.
1) SERP intent & what the top results typically cover
For keywords like React data grid, React data table, and React grid component,
the dominant intent is mixed: users want quick comparisons (commercial-ish), but they also want implementation details (informational).
Pages that rank usually combine: “what it is,” “why pick it,” a minimal working example, and a feature checklist.
For queries such as AG Grid tutorial, AG Grid React example, and AG Grid React setup,
the intent is strongly informational with a hands-on bias. Winning pages don’t over-explain tables; they show installation, CSS theme wiring,
column definitions, row data binding, and then immediately jump into sorting/filtering/pagination and editing.
For AG Grid installation specifically, the intent is narrow and task-oriented (“tell me the commands and required imports, now”).
Top pages typically include: the npm/yarn command, a short note about community vs enterprise packages, required theme CSS, and a basic component that renders.
Anything that hides those steps behind a “marketing intro” tends to underperform—developers are patient, but not that patient.
2) AG Grid installation in React (the part most people mess up)
Let’s make this painless. For a standard React app (Vite, CRA, Next.js client components), you install the grid package and the React wrapper.
AG Grid has a Community edition (free) and Enterprise features (licensed). You can build a very capable React table component on Community alone.
The second most common issue after installation is styling: the grid will render, but look broken because the theme CSS wasn’t imported.
So we’ll do installation and theme wiring as one “atomic” step, because that’s how your future self will want to see it.
Here’s the minimal setup for AG Grid React setup that reliably works across projects (adjust the imports if your bundler requires it).
# npm
npm i ag-grid-community ag-grid-react
# or yarn
yarn add ag-grid-community ag-grid-react
# or pnpm
pnpm add ag-grid-community ag-grid-react
// App.tsx (or any component)
import React, { useMemo } from "react";
import { AgGridReact } from "ag-grid-react";
import "ag-grid-community/styles/ag-grid.css";
import "ag-grid-community/styles/ag-theme-quartz.css";
type Row = {
make: string;
model: string;
price: number;
inStock: boolean;
};
export default function App() {
const rowData: Row[] = [
{ make: "Tesla", model: "Model Y", price: 48990, inStock: true },
{ make: "Ford", model: "F-150", price: 38990, inStock: false },
{ make: "Toyota", model: "Corolla", price: 21990, inStock: true }
];
const colDefs = useMemo(
() => [
{ field: "make" },
{ field: "model" },
{ field: "price" },
{ field: "inStock" }
],
[]
);
return (
<div style={{ height: 420 }} className="ag-theme-quartz">
<AgGridReact rowData={rowData} columnDefs={colDefs} />
</div>
);
}
3) Build a real React data grid: columns, defaults, and performance basics
A “hello world” grid is cute, but production grids need sane defaults. Most high-ranking tutorials set defaultColDef early:
it reduces repetition and makes your React data grid library feel consistent across screens. It also helps you ship features (resize, sort, filter) without
turning every column into a novella.
Performance-wise, AG Grid uses virtualization, so it’s comfortable with large datasets—but you still want stable references
for column definitions and defaults. That’s why we use useMemo. Not because it’s trendy, but because it prevents unnecessary recalculation
and re-render churn when React does React things.
Here’s a more realistic AG Grid React example that you can evolve into a dashboard-grade React data table.
import React, { useMemo, useState, useCallback } from "react";
import { AgGridReact } from "ag-grid-react";
import type { ColDef, GridReadyEvent } from "ag-grid-community";
import "ag-grid-community/styles/ag-grid.css";
import "ag-grid-community/styles/ag-theme-quartz.css";
type Row = {
id: number;
make: string;
model: string;
price: number;
inStock: boolean;
};
export function CarsGrid() {
const [rowData, setRowData] = useState<Row[]>([
{ id: 1, make: "Tesla", model: "Model 3", price: 39990, inStock: true },
{ id: 2, make: "Ford", model: "Mustang", price: 55990, inStock: false },
{ id: 3, make: "Toyota", model: "Camry", price: 28990, inStock: true },
{ id: 4, make: "BMW", model: "i4", price: 52990, inStock: true }
]);
const defaultColDef = useMemo<ColDef>(
() => ({
sortable: true,
filter: true,
resizable: true,
flex: 1,
minWidth: 120
}),
[]
);
const columnDefs = useMemo<ColDef[]>(
() => [
{ headerName: "ID", field: "id", maxWidth: 110, filter: "agNumberColumnFilter" },
{ headerName: "Make", field: "make", filter: "agTextColumnFilter" },
{ headerName: "Model", field: "model", filter: "agTextColumnFilter" },
{
headerName: "Price",
field: "price",
filter: "agNumberColumnFilter",
valueFormatter: (p) => `$${Number(p.value).toLocaleString()}`
},
{ headerName: "In stock", field: "inStock", filter: "agSetColumnFilter" }
],
[]
);
const onGridReady = useCallback((e: GridReadyEvent) => {
// Example: fit columns once data is ready (optional)
e.api.sizeColumnsToFit();
}, []);
return (
<div style={{ height: 520 }} className="ag-theme-quartz">
<AgGridReact
rowData={rowData}
columnDefs={columnDefs}
defaultColDef={defaultColDef}
onGridReady={onGridReady}
animateRows={true}
rowSelection="multiple"
/>
</div>
);
}
4) Filtering, sorting, and pagination (aka the reason you installed a grid)
Users don’t ask for “a table.” They ask for “a table where I can find things.” That’s why AG Grid filtering sorting keywords show up so often.
In AG Grid, sorting and filtering are typically enabled per-column (or via defaultColDef), and you can layer on more advanced filters without rewriting your UI.
Pagination is a common requirement for admin panels and data-heavy screens, and it’s also a frequent search: AG Grid pagination.
While AG Grid can handle large lists with virtualization, pagination still matters when you have server-side data, strict UX patterns,
or you want to reduce cognitive overload (“please don’t show me 5,000 rows at once”).
The snippet below adds client-side pagination and shows how to provide a more explicit “this grid is interactive” configuration.
It’s a clean baseline for an interactive table React implementation.
<AgGridReact
rowData={rowData}
columnDefs={columnDefs}
defaultColDef={defaultColDef}
animateRows
// Pagination
pagination={true}
paginationPageSize={10}
paginationPageSizeSelector={[10, 25, 50, 100]}
// UX: show filters in floating row (optional)
floatingFilter={true}
/>
If you’re building a serious React grid component, you’ll also want to consider server-side filtering/sorting/pagination later.
But don’t start there unless you truly need it—client-side features are fast to ship, easy to validate with users, and usually enough for MVP and internal tooling.
5) Cell editing: turning a React data table into a workflow
Searchers who type AG Grid cell editing usually have one of two problems: they need inline edits (spreadsheet vibes),
or they need validation and controlled updates (so the grid doesn’t become a “type anything, break everything” playground).
AG Grid supports both patterns, and you can start simple: mark columns editable and listen for change events.
If you want a React spreadsheet table feel, you’ll quickly care about keyboard navigation, value parsing, and validation.
The good news: AG Grid has editors, formatters, parsers, and events. The bad news: you now have choices—many choices.
Don’t panic; start with editable: true and onCellValueChanged.
Here’s a practical editing configuration with basic validation and state update. It keeps edits predictable and makes server syncing straightforward.
import type { ColDef, CellValueChangedEvent, ValueParserParams } from "ag-grid-community";
const columnDefs: ColDef[] = [
{ field: "make", editable: true },
{ field: "model", editable: true },
{
field: "price",
editable: true,
filter: "agNumberColumnFilter",
valueParser: (p: ValueParserParams) => {
const next = Number(p.newValue);
return Number.isFinite(next) ? next : p.oldValue; // basic guard
}
},
{ field: "inStock", editable: true, cellEditor: "agSelectCellEditor", cellEditorParams: { values: [true, false] } }
];
function onCellValueChanged(e: CellValueChangedEvent) {
// Example: update local state (or trigger API call)
// e.data contains updated row
console.log("Row updated:", e.data);
}
<AgGridReact
rowData={rowData}
columnDefs={columnDefs}
defaultColDef={defaultColDef}
onCellValueChanged={onCellValueChanged}
/>;
If your product owner asks for “Excel, but in the browser,” pause and clarify scope before you build a full spreadsheet clone.
AG Grid can get you far, but the last 10% (formulas, multi-cell copy rules, audit history) is where time goes to do push-ups.
6) Quick feature checklist (what competitors usually highlight)
In top-ranking guides, authors typically call out the same set of capabilities because they match the common “why this grid” evaluation flow.
People comparing a React table component want to know: can it sort/filter, can it edit, does it paginate, does it scale, and how hard is it to theme?
If you’re evaluating React data grid library options, keep the decision criteria brutally practical: developer time, bundle size, licensing constraints,
accessibility needs, and whether you’ll need advanced features (grouping, pivoting, server-side row model).
Here’s the short list that usually convinces teams they’re in “grid land,” not “table land”:
- Sorting & filtering per column (text, number, set filters, floating filters)
- Pagination (client-side; server-side patterns supported)
- Cell editing with editors, parsers, validation hooks
- Virtualization for large datasets
- Theming via CSS themes (Quartz, Alpine, etc.)
For an extended walkthrough that aligns with what many developers search for (advanced tables, richer configuration, and real-world features),
see this reference: AG Grid tutorial on dev.to.
And when you’re ready to go deeper than any blog post can, the most direct source remains the official
AG Grid React docs.
FAQ
Is AG Grid free for React projects?
Yes—AG Grid Community is free and covers many common needs (sorting, filtering, pagination, basic editing). Some advanced features are Enterprise and require a license.
Why is my AG Grid blank or unstyled after installation?
The most common cause is missing theme CSS. Import ag-grid.css and a theme (for example, ag-theme-quartz.css) and add the theme class to the container.
How do I add sorting, filtering, and pagination in AG Grid React?
Enable sortable and filter in defaultColDef, then set pagination={true} and paginationPageSize on <AgGridReact />.
Semantic core (expanded keyword map)
Primary cluster (core intent)
AG Grid React, React data grid, React data grid library, React grid component,
React data table, React table component
Setup & onboarding cluster
AG Grid installation, AG Grid React setup, AG Grid React install, AG Grid React TypeScript setup,
AG Grid CSS theme import, ag-theme-quartz, AG Grid React Vite, AG Grid React Next.js
Tutorial / examples cluster
AG Grid tutorial, AG Grid React example, AG Grid React sample project, AG Grid columnDefs example,
AG Grid rowData example, React table example AG Grid
Interactive features cluster
interactive table React, AG Grid filtering sorting, AG Grid filter types, AG Grid floating filter,
multi-column sorting, set filter, text filter, number filter
Pagination & UX cluster
AG Grid pagination, paginationPageSize, paginationPageSizeSelector, server-side pagination React,
client-side pagination data grid
Editing / spreadsheet-like cluster
AG Grid cell editing, inline editing React grid, AG Grid valueParser, onCellValueChanged,
React spreadsheet table, editable data table React
LSI & synonyms (supporting language)
data table, data grid, grid component, tabular UI, column configuration, row model, virtualization, table sorting, table filtering,
inline edit, select editor, validation, performance, theming
Popular user questions (PAA-style pool)
- How do I install AG Grid in React?
- Is AG Grid free or paid?
- Why is AG Grid not showing (blank) in React?
- How do I enable sorting and filtering in AG Grid React?
- How do I add pagination in AG Grid?
- How do I make cells editable in AG Grid React?
- AG Grid vs Material UI DataGrid: which is better?
- How do I load server-side data into AG Grid React?
- How do I style AG Grid (themes) in React?
- Does AG Grid work well with TypeScript?
Backlinks (outbound references)
Official product page: AG Grid React
Reference tutorial: AG Grid tutorial

