A pagination extension for Prisma ORM that adds a convenient `paginate()` method to Prisma client instances. Version 0.2.1, released in 2023, with weekly updates. It integrates via Prisma's `$extends` API (≥4.9.0), supports both combined and separate arguments, works with raw SQL via a `Pagination` utility, and returns `result`, `totalPages`, `hasNextPage`, `hasPrevPage`, and `count`. Unlike wrapper libraries, it uses the official extension mechanism, making it compatible with future Prisma versions and TypeScript types.
npm install prisma-paginate-extensionNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic setup: create a Prisma client, extend it with PrismaPaginate, and run a paginated query with where filter and pagination args.
Update logic: `totalPages` is always a number. Use `result.count` for unknown counts.
Use `prisma.$extends(PrismaPaginate)` to create an extended client. The method is available on the extended client, not the original PrismaClient.
Always call `prisma.$extends(PrismaPaginate)` first and use the resulting client.
Pass pagination args as separate properties or as second argument. Example: `paginate({ where: {} }, { page: 1, limit: 10 })`If you need the count inside `onCount`, read `pagination.count` (a number). The `Pagination` object also has `offset()` and `limit()` methods.
Create extended client: `const xprisma = prisma.$extends(PrismaPaginate);` then use `xprisma.user.paginate()`.
Install the package: `npm install prisma-paginate-extension`. Import as default: `import PrismaPaginate from 'prisma-paginate-extension';`.
Define type for extended client: `import { PrismaClient } from '@prisma/client'; import PrismaPaginate from 'prisma-paginate-extension'; type ExtendedPrismaClient = ReturnType<typeof PrismaClient['prototype']['$extends']>;` Or use a type assertion.Ensure prisma instantiation and $extends happen in an async function or module scope with top-level await support.