npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dessly/prisma-cursor-paginate

v0.2.1-1.0.0

Published

Paginate ORM Prisma

Readme

📖 prisma-paginate

| npm version | CI | pages-build-deployment | | -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

🚀 Installation

# Using npm
npm install prisma @prisma/client prisma-paginate

# Using yarn
yarn add prisma @prisma/client prisma-paginate

# Using pnpm
pnpm add prisma @prisma/client prisma-paginate

📋 Version compatibility

| Prisma | prisma-paginate | | -------- | --------------- | | 7.0.0>= | 6.0.0 | | 4.16.0<= | 5.2.2 |

📚 Documentation

For comprehensive API documentation and type definitions, visit:

http://sandrewtx08.github.io/prisma-paginate/

📦 Importing

ESM (ES Modules)

// Standard Prisma client
import { PrismaClient } from "@prisma/client";
import PrismaPaginate from "prisma-paginate";

// Custom Prisma client paths also work
import { PrismaClient } from "./generated/client";
import PrismaPaginate from "prisma-paginate";

CommonJS

const { PrismaClient } = require("@prisma/client");
const PrismaPaginate = require("prisma-paginate").default;

Note: The extension works seamlessly with any Prisma client instance, regardless of the import path. No additional configuration needed!

🔧 Usage

Basic Setup

const prisma = new PrismaClient();
const xprisma = prisma.$extends(PrismaPaginate);

// Simple cursor pagination
xprisma.user
	.cursorPaginate({
		limit: 10,
		orderBy: { id: "asc" },
		cursorFields: ["id"] as const,
		select: { id: true, name: true },
	})
	.then((result) => {
		console.log(result.result);
		console.log(result.hasNextPage);
		console.log(result.nextCursor);
	});

// Pagination with filters and cursor
xprisma.post
	.cursorPaginate(
		{
			where: { published: true },
			orderBy: [{ createdAt: "desc" }, { id: "desc" }],
			cursorFields: ["createdAt", "id"] as const,
		},
		{ limit: 10, cursor: lastCursor },
	)
	.then((result) => {
		console.log(result.result);
	});

Complete Example

// Assume database has 100 rows: [ { id: 1 }, { id: 2 }, ..., { id: 100 } ]
const first = await xprisma.user.cursorPaginate({
	where: {
		active: true,
	},
	orderBy: [{ createdAt: "desc" }, { id: "desc" }],
	limit: 50,
	cursorFields: ["createdAt", "id"] as const,
});

console.log(first.result); // Array of 50 users
console.log(first.hasNextPage); // true if there's a next page
console.log(first.nextCursor); // cursor for the next page

if (first.hasNextPage) {
	const second = await xprisma.user.cursorPaginate(
		{
			where: {
				active: true,
			},
			orderBy: [{ createdAt: "desc" }, { id: "desc" }],
			cursorFields: ["createdAt", "id"] as const,
		},
		{ limit: 50, cursor: first.nextCursor },
	);

	console.log(second.result);
}

📋 API Reference

Method Signatures

// Option 1: Combined findMany args and pagination
cursorPaginate(findManyPaginationArgs: PrismaFindManyArgs & PaginationArgs)

// Option 2: Separate findMany args and pagination
cursorPaginate(findManyArgs: PrismaFindManyArgs, paginationArgs: PaginationArgs)

Parameters

findManyArgs (Object)

Standard Prisma findMany arguments including:

  • where - Filter conditions
  • select - Fields to select
  • include - Relations to include
  • orderBy - Sorting options
  • And all other Prisma query options

paginationArgs (Object)

Pagination configuration:

  • limit (Number) - Number of items per page
  • cursor (Object) - Cursor values from the previous page
  • cursorFields (Array) - Ordered unique cursor field names (must match orderBy)

Note: When using cursor pagination, orderBy is required. The cursorFields list is required, must be unique fields, and must match the orderBy fields and order.

Return Value

The cursorPaginate() method returns a Promise<PaginationResult> with the following properties:

| Property | Type | Description | | ------------- | -------- | ----------------------------------------- | | result | Array | Array of paginated records | | limit | Number | Page size | | hasNextPage | Boolean | Whether a next page exists | | nextCursor | Object | Cursor values for the next page | | nextPage | Function | Returns Promise to fetch the next page |

✨ Features

  • 🚀 Easy Integration - Simple Prisma extension setup
  • 📦 TypeScript Support - Full type safety with IntelliSense
  • 🔄 Flexible API - Multiple ways to call pagination
  • 📊 Cursor Metadata - hasNextPage and typed nextCursor
  • 🎯 Prisma Native - Works with all Prisma query options
  • Zero Config - Works out of the box with any Prisma setup

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

🔗 Links