How to paginate blog posts with next.js

Hello iā€™m trying to paginate a blog but still couldnā€™t find the way to do it with datocms. Iā€™m fairly new to building websites. Iā€™ve read the documentation https://www.datocms.com/docs/content-delivery-api/pagination and search tutorials on the internet but still havenā€™t found the best way to do it with datocms. If thereā€™s anyone who can help me on this it will be much appreciated. Here is the website that iā€™ve been working on https://www.wangsakerta.org/catatanlapangan. Thanks in advance

Hello @yayasan.wangsakerta and welcome to the community!

The best way to do it, is to pass the page index (that is, the number of the page) as a multiplier to the ā€œskipā€ parameter.
Lets say you want to paginate your posts having 6 posts per page.
You would do the following request:

{
  allPosts(first: 6, skip: 6 * index) {
    id
    author
  }
}

This will make it so this request always return 6 records, and skips the firsts 6 * index records.
So if you are on the page with:

index = 1 you will get post 1- 6
index = 2 you will get posts 7-12
index = 3 you will get posts 13-18

And so on.