Calculate several records.
Ignore the previous records.
First : (pageNumber -1 )0* page size
0*6 = 0 // skip the first 0 records.
Second : (2-1)*6 = 6 records skipped.
Third : (3-1) *6 = 12 records skipped.
Data.find({}). limit(page size).skip(inject the above formula).
Calculate a number of pages: math.ceil(total records / page size).
Pass the total page as a prop to the pagination component.
Pass the current page as a prop to the pagination component for highlighting the current page.
Previous and Next buttons :
Previous button : <Link href={/?page=${current page -1}} />
Next button : <Link href={/page=${current page + 1}} />