express-paginate is a Node.js middleware and view helper library designed for pagination within Express applications. It provides utilities to handle `req.skip` (aliased as `req.offset`), `req.query.limit`, and `req.query.page` automatically, simplifying the process of fetching paginated results from a database and generating pagination links. The current stable version is 1.0.2, released in 2016. The package has seen no significant updates or active development since then, indicating an effectively abandoned status. It differentiates itself by providing both server-side request parsing for pagination parameters and a view helper function (`paginate.href`) for rendering pagination controls in templates, integrating directly into the Express `req` and `res.locals` objects.
npm install express-paginateVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes an Express application with `express-paginate` middleware. It demonstrates how to apply pagination to a dummy dataset, using `req.skip` and `req.query.limit` to slice results, and mentions the `res.locals.paginate.href` helper for generating navigation links. It also includes the recommended security fix for `limit=0`.
Update database queries to use `req.skip` (e.g., `Model.find().skip(req.skip)`).
Implement a custom middleware to enforce a minimum or default `limit` value if `req.query.limit` is `0` or too low (e.g., `if (req.query.limit <= 10) req.query.limit = 10;`).
Consider migrating to a more actively maintained pagination library or implementing custom pagination logic, especially for new projects or applications requiring robust security and long-term support.
Ensure your project or file uses `require('express-paginate')` for importing the library. If using a pure ESM environment, you may need a wrapper or a different library.Ensure you are using `const paginate = require('express-paginate');` and then calling `app.use(paginate.middleware(...));`.Verify that `app.use(paginate.middleware(limit, maxLimit));` is called globally or on the specific routes *before* the route handler that accesses `req.skip`.
Review middleware order and ensure only one response is sent per request-response cycle. Place `express-paginate` early in the middleware chain if it's meant to apply broadly.
No dependency data recorded yet.