I'm currently working on a project with NextJs + Prismic, where I need to get only a small amount of documents (for performance reasons) and I tried to use the pageSize parameter but it seems like it doesn't work. It's set to pageSize=3 but it always returns all the documents.
I've also searched for similar issues and it seems like other users had problems with it too.
Welcome to the Prismic community and thanks for reaching out to us.
pageSize parameters should return 3 documents if it's set so. I can not recreate the issue with my repository. If you can send me your repo URL I'll check with it(You can send me a private message though)
1. getAllByType() with limit: getAllByType() will fetch all documents. To limit the number of documents returned, the limit option can be passed. Once the function reaches that limit, it will stop requesting pages.
await client.getAllByType('page', { limit: 3 })
2. getByType() with pageSize: getByType() only fetches one page, thus pageSize will limit the results to the size of that single page. The response will include the pagination metadata along with the data using this method, however, so you’ll need to access the results using res.results.