Michael Tromba
Michael Tromba

An open source pagination library for Drizzle ORM

Cursor pagination helper I built for myself and shared with the Drizzle community.

An open source pagination library for Drizzle ORM

While building 52x Grow, I migrated from a heavier ORM to Drizzle for a thinner, closer-to-SQL database layer. Drizzle was great for that — but it meant writing my own cursor pagination logic from scratch every time I needed it. The boilerplate was brittle: if one condition was off in the where clause, pagination would silently break with results in the wrong order or skipped rows.

After rewriting the same pattern enough times, I pulled my working implementation into a standalone utility. drizzle-pagination is about 100 lines of TypeScript that generates the where, orderBy, and limit conditions for cursor-based pagination queries. It handles both single-cursor pagination (by a unique column like id) and double-cursor patterns (by a non-unique column like publishedAt with a unique fallback for stable ordering). You spread the result into a Drizzle findMany call and it just works.

Drizzle was still pretty new at the time, and I was active in some of the community discussions around common pain points. Pagination kept coming up — other developers were hitting the exact same wall I had. So I published the package to npm and shared it. It picks up around 6,000 downloads a month now, with 65 stars on GitHub.