What this thread does
Do first: add the base table with pnpm dlx shadcn@latest add table, then install @tanstack/react-table with pnpm add @tanstack/react-table.
Short answer
The current shadcn guide builds a custom table with TanStack Table v9. Its feature registration, controlled state, and column callbacks provide sorting and filtering. The guide supplies a construction pattern rather than a single preassembled DataTable component.
What to do
Use the guide’s four-file layout under app/payments/:
| File | Responsibility |
|---|---|
columns.tsx | Client-side column definitions. |
data-table-features.ts | Shared feature registration and its type. |
data-table.tsx | Client-side reusable table. |
page.tsx | Fetch data and render the table in the Next.js example. |
Register the behaviors before wiring the UI. These are the guide’s v9 APIs:
| Part | Concrete API or setting |
|---|---|
| Feature container | tableFeatures(); export features and DataTableFeatures = typeof features. |
| Sorting | rowSortingFeature; sortedRowModel: createSortedRowModel(). |
| Filtering | columnFilteringFeature; filteredRowModel: createFilteredRowModel(). |
| Pagination | rowPaginationFeature; paginatedRowModel: createPaginatedRowModel(); default page size is 10. |
| Filter function | filterFns: { includesString: filterFn_includesString }. |
| Sort functions | sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }. |
| Column helper | createColumnHelper<DataTableFeatures, Payment>() in the example; replace Payment with the row type. |
| Table instance | useTable({ features, data, columns, ... }). |
| Controlled sorting | Start sorting at []; provide state.sorting and onSortingChange: setSorting. |
| Controlled filters | Start columnFilters at []; provide state.columnFilters and onColumnFiltersChange: setColumnFilters. |
For the example’s email header, connect column.toggleSorting(column.getIsSorted() === "asc"); it toggles ascending/descending order. The filter input reads table.getColumn("email")?.getFilterValue() with an empty-string fallback and writes through table.getColumn("email")?.setFilterValue(event.target.value). For another column, replace email with that column’s identifier. Sorting and filtering examples.
Limits and open questions
This guide explicitly targets v9. Optional row models now use create*RowModel() inside the feature object; the former get*RowModel table options are no longer used by this pattern. The core row model is included automatically. Its demonstrated filter targets the email column; server request design is outside that example. Version and feature notes.
Not for: TanStack Table v8 get*RowModel table options or server-side query fetching.
Sources
Checked
2026-11-17: read the shadcn Data Table guide’s installation, structure, v9 features, sorting, filtering, and pagination sections; no command was run.
Started from a post by @shadcn/ui, packaged by the editor. Original post