Exposes a connect middleware to easily parse and create pagination query strings.

npm install connect-pagination
12 downloads in the last month


Very simple and easy to use connect (express) middleware for parsing pagination query strings.


$ npm install connect-pagination

Quick Start with Connect.js or Express.js

var connect    = require('connect'),
    pagination = require('connect-pagination')

var paginationOptions = {
    pageParam: 'p'

    .use(function (req, res) {

Available Options

  • pageParam specifies the query param for the page number (defaults to page)
  • ippParam specifies the query param for the number of items per page (defaults to ipp)
  • page the default page number (defaults to 1)
  • ipp the default number of items per page (defaults to 24)

The req.pagination object

Through req.pagination the following object becomes available:

  • page the current requested page number
  • ipp the current requested number of items per page
  • Function buildQuery(page, ipp) returns a query string like ?page=4&ipp=20
  • Function addQuery(url, page, ipp) adds the pagination query to the url given



  • The pagination object is now attached to res.locals so that it can be used in express remplates
npm loves you