Pagination for Results

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 : All of the documents of the custom type "recipe” allowing 100 documents per page.

Copy
      api.query(
    Prismic.Predicates.at('document.type', 'recipe'),
    { pageSize : 100 }
).then(function(recipes) {
    // recipes is the response object, recipes.results holds the documents
});
    
Copy
      $recipes = $api->query(
    Predicates::at('document.type', 'recipe'),
    [ 'pageSize' => 100 ]
);
// $recipes contains the response object, $recipes->getResults() holds the documents
    
Copy
      recipes = api.query(
    Prismic::Predicates.at("document.type", "recipe"),
    { "pageSize" => 100 }
)
# recipes contains the response object, recipes.results holds the documents
    

page

The page option defines the pagination for the result of your query. Defaults to "1", corresponding to the first page.

Set the page option as shown in the example below.

Example : All of the documents of the custom type "recipe” limited to 50 recipes per page, showing the third page of results.

Copy
      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
});
    
Copy
      $recipes = $api->query(
    Predicates::at('document.type', 'recipe'),
    [ 'pageSize' => 50, 'page' => 3 ]
);
// $recipes contains the response object, $recipes->getResults() holds the documents
    
Copy
      recipes = api.query(
    Prismic::Predicates.at("document.type", "recipe"),
    { "pageSize" => 50, "page" => 3 }
)
# recipes contains the response object, recipes.results holds the documents