Components/usePagination

usePagination

All pagination logic decoupled from UI. Returns current page, total pages, and navigation helpers.

Installation

Usage

API Reference

PropTypeDefaultDescription
pagenumber—Current 1-based page number.
pageSizenumber—Items per page.
totalPagesnumber—Calculated total pages.
fromnumber—First item index on current page.
tonumber—Last item index on current page.
hasPrevboolean—True when page > 1.
hasNextboolean—True when page < totalPages.
goTo(page) => void—Navigate to a specific page.
goNext() => void—Go to the next page.
goPrev() => void—Go to the previous page.
setPageSize(n) => void—Change items per page.