Pagination for Results in Javascript

The results retrieved from the prismic.io repository will automatically be paginated. Here you will find an explanation for how to modify the pagination parameters.

pageSize

The pageSize option defines the maximum number of documents that the API will return for your query. Default is 20, max is 100.

Set the pageSize option as shown in the example below.

Example: This demonstrates how to query all of the documents of the custom type "recipe,” allowing 100 documents per page.

Copy
//To retreive the API object check how to query the API
api.query(
    Prismic.Predicates.at('document.type', 'recipe'),
    { pageSize : 100 }
).then(function(recipes) {
    // recipes is the response object, recipes.results holds the documents
});

page

The page option defines the pagination for the result of your query. If unspecified, this field defaults to "1", corresponding to the first page or results.

Set the page option as shown in the example below.

Example : This demonstrates how to query all of the documents of the custom type "recipe” limited to 50 recipes per page, showing the third page of results.

Copy
//To retreive the API object check how to query the API
api.query(
    Prismic.Predicates.at('document.type', 'recipe'),
    { pageSize : 50, page : 3 }
).then(function(recipes) {
    // recipes is the response object, recipes.results holds the documents
});