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 Yayasan Wangsakerta. 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.