Pagination
The ability to split up large data sets into smaller chunks.
State
Pagination state is stored on the table using the following shape:
export type PaginationState = {
  pageIndex: number
  pageSize: number
}
 
export type PaginationTableState = {
  pagination: PaginationState
}
 
export type PaginationInitialTableState = {
  pagination?: Partial<PaginationState>
}export type PaginationState = {
  pageIndex: number
  pageSize: number
}
 
export type PaginationTableState = {
  pagination: PaginationState
}
 
export type PaginationInitialTableState = {
  pagination?: Partial<PaginationState>
}Table Options
manualPagination
manualPagination?: booleanmanualPagination?: booleanEnables manual pagination. If this option is set to true, the table will not automatically paginate rows using getPaginationRowModel() and instead will expect you to manually paginate the rows before passing them to the table. This is useful if you are doing server-side pagination and aggregation.
pageCount
pageCount?: numberpageCount?: numberWhen manually controlling pagination, you should supply a total pageCount value to the table if you know it. If you do not know how many pages there are, you can set this to -1.
autoResetPageIndex
autoResetPageIndex?: booleanautoResetPageIndex?: booleanIf set to true, pagination will be reset to the first page when page-altering state changes eg. data is updated, filters change, grouping changes, etc.
🧠Note: This option defaults to
falseifmanualPaginationis set totrue
onPaginationChange
onPaginationChange?: OnChangeFn<PaginationState>onPaginationChange?: OnChangeFn<PaginationState>If this function is provided, it will be called when the pagination state changes and you will be expected to manage the state yourself. You can pass the managed state back to the table via the tableOptions.state.pagination option.
getPaginationRowModel
getPaginationRowModel?: (table: Table<TData>) => () => RowModel<TData>getPaginationRowModel?: (table: Table<TData>) => () => RowModel<TData>Returns the row model after pagination has taken place, but no further.
Pagination columns are automatically reordered by default to the start of the columns list. If you would rather remove them or leave them as-is, set the appropriate mode here.
Table API
setPagination
setPagination: (updater: Updater<PaginationState>) => voidsetPagination: (updater: Updater<PaginationState>) => voidSets or updates the state.pagination state.
resetPagination
resetPagination: (defaultState?: boolean) => voidresetPagination: (defaultState?: boolean) => voidResets the pagination state to initialState.pagination, or true can be passed to force a default blank state reset to [].
setPageIndex
setPageIndex: (updater: Updater<number>) => voidsetPageIndex: (updater: Updater<number>) => voidUpdates the page index using the provided function or value.
resetPageIndex
resetPageIndex: (defaultState?: boolean) => voidresetPageIndex: (defaultState?: boolean) => voidResets the page index to its initial state. If defaultState is true, the page index will be reset to 0 regardless of initial state.
setPageSize
setPageSize: (updater: Updater<number>) => voidsetPageSize: (updater: Updater<number>) => voidUpdates the page size using the provided function or value.
resetPageSize
resetPageSize: (defaultState?: boolean) => voidresetPageSize: (defaultState?: boolean) => voidResets the page size to its initial state. If defaultState is true, the page size will be reset to 10 regardless of initial state.
setPageCount
setPageCount: (updater: Updater<number>) => voidsetPageCount: (updater: Updater<number>) => voidUpdates the page count using the provided function or value.
getPageOptions
getPageOptions: () => number[]getPageOptions: () => number[]Returns an array of page options (zero-index-based) for the current page size.
getCanPreviousPage
getCanPreviousPage: () => booleangetCanPreviousPage: () => booleanReturns whether the table can go to the previous page.
getCanNextPage
getCanNextPage: () => booleangetCanNextPage: () => booleanReturns whether the table can go to the next page.
previousPage
previousPage: () => voidpreviousPage: () => voidDecrements the page index by one, if possible.
nextPage
nextPage: () => voidnextPage: () => voidIncrements the page index by one, if possible.
getPageCount
getPageCount: () => numbergetPageCount: () => numberReturns the page count. If manually paginating or controlling the pagination state, this will come directly from the options.pageCount table option, otherwise it will be calculated from the table data using the total row count and current page size.
getPrePaginationRowModel
getPrePaginationRowModel: () => RowModel<TData>getPrePaginationRowModel: () => RowModel<TData>Returns the row model for the table before any pagination has been applied.
getPaginationRowModel
getPaginationRowModel: () => RowModel<TData>getPaginationRowModel: () => RowModel<TData>Returns the row model for the table after pagination has been applied.
Credits
- Pagination - TanStack Table 
v8Docs