gridcn1.2.2

Client mode

useDataGridPagination slicing a full dataset, for a table that already fits in the browser.

Client mode: the demo holds all 240 rows and the hook slices the current page out of them. No round trip, and no total to manage. You need pageSize and, optionally, a controlled page.

Name
Email
Role
Score
Silent Tiger
user0@example.com
Viewer
4
Quick Lion
user1@example.com
Viewer
89
Swift Wolf
user2@example.com
Manager
80
Eager Lion
user3@example.com
User
51
Eager Tiger
user4@example.com
Viewer
83
Silent Wolf
user5@example.com
User
15
Swift Lion
user6@example.com
Viewer
62
Eager Lion
user7@example.com
Manager
42
Eager Eagle
user8@example.com
Editor
35
Bold Tiger
user9@example.com
Editor
52
Bold Bear
user10@example.com
User
28
Swift Wolf
user11@example.com
Manager
9
Swift Bear
user12@example.com
Viewer
45
Eager Wolf
user13@example.com
Editor
44
Swift Eagle
user14@example.com
Viewer
51
Quick Lion
user15@example.com
Manager
28
Bold Wolf
user16@example.com
Editor
76
Swift Eagle
user17@example.com
Admin
26
Eager Eagle
user18@example.com
Manager
70
Eager Bear
user19@example.com
Editor
67
Silent Lion
user20@example.com
Manager
89
Silent Tiger
user21@example.com
Manager
40
Eager Tiger
user22@example.com
Manager
82
Silent Lion
user23@example.com
Admin
16
Bold Eagle
user24@example.com
Admin
38
1–25 of 240
pnpm dlx shadcn@latest add @gridcn/data-grid-pagination-demo

Client slice vs server mode

// client mode — the hook slices `data` for you
const pager = useDataGridPagination({ data: rows, pageSize: 25 });

// server mode — you own page/pageSize/total and fetch the page yourself
const pager = useDataGridPagination({
  page,
  pageSize,
  total: serverTotal,
  onPageChange: setPage,
  onPageSizeChange: (next) => {
    setPageSize(next);
    setPage(1);
  },
});

Both return the same controls shape, so <DataGridPaginationBar {...pager.controls} /> doesn't need to know which mode it's in. The footer sits outside the provider in both cases, so it reads no store.

Use client mode when the dataset already fits in memory (a few hundred to a few thousand rows). Switch to server mode when a page is a real API call. See TanStack Query and SWR.

Behavior reference

  • Pagination: the add-on reference, including the composable footer parts
  • Server side: the full remote contract, not just pages

On this page