Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Facets 3.0.7 Minor update available for module facets (3.0.7). Release: Superfish Dropdown Menu 8.x-1.16 Minor update available for module superfish (8.x-1.16). Release: Prototype 5.6.0 Minor update available for theme prototype (5.6.0). Release: Prototype 5.5.1 Minor update available for theme prototype (5.5.1). Release: Native Observability 1.1.0 Minor update available for module native_observability (1.1.0). Release: Educare theme 1.0.0 Initial release available for theme vartheme_bs5_educare (1.0.0)! Release: Horizon Aid theme 1.0.0 Initial release available for theme vartheme_bs5_horizonaid (1.0.0)! Release: Vartheme Bs5 5.0.1 Minor update available for theme vartheme_bs5 (5.0.1). Usage Milestone: Shortcode Module shortcode crossed 1,000 active installs. Module Revived: PDF using mPDF 3.0.1 Module pdf_using_mpdf updated after 13 months of inactivity (3.0.1).

Pager Serializer

1,516 sites Security covered Drupal 10–11
View on drupal.org

This module enhances Drupal's serialization capabilities for REST APIs, automatically including pagination information like total items and pages directly in the response. This eliminates the need for separate API calls to fetch pagination details, streamlining data retrieval for decoupled front-end applications.

The Page Serializer extends the default Serializer to include pagination data. This module is intended to be used with rest and the Rest export View with a decoupled UI. Including the pagination, data lets the front end know the total record count and other useful information. This eliminates the need to make another rest endpoint to get the total number of records.

Configuration

  1. Navigate to Administration > Structure > Views > Add view and create a
    new view of REST EXPORT
  2. In the Format, select the 'Pager Serializer'.
  3. On the style settings, provide the Accepted request formats to use.
  4. In the Pager, select the 'Paged output, full pager'
  5. Save the settings and view the result.

Sample output

Pager Serializer produces output like the following.

{
  rows: [
    {...},
    {...}
  ],
  pager: {
    current_page: 0,
    total_items: 6,
    total_pages: 2,
    items_per_page: 5,
  }
}

Using Serializer with Views, only the rows are returned. This module extends Serializer to return the pagination data. All the property names are customizable, and properties can be disabled to meet the needs of the front end.

Views Serialization Pager is another contributed module which also exposes pagination data.

Develop Pager Serializer using DDEV ⚙

If you haven't already, install DDEV.

git clone [email protected]:project/pager_serializer.git
cd pager_serializer
ddev config --project-type=drupal --docroot=web --php-version=8.4 --corepack-enable --project-name=pager-serializer
ddev add-on get ddev/ddev-drupal-contrib
ddev add-on get s-ayers/ddev-drupal-contrib-mkdocs
ddev start
ddev poser
ddev symlink-project
ddev drush site:install -y
ddev drush pm:install pager_serializer -y
ddev drush config:export -y
ddev drush user:login

Depends on

Dependencies of the latest stable release

  • rest Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Oct 2024
Latest release
1 month ago
Releases (12 mo)
1
Maintenance
Active

Releases

Version Type Core Release date
2.0.x-dev Dev 11 Jul 23, 2026
8.x-1.3 Stable 10–11 Oct 26, 2024