Skip to content

Different Pagination Types

In this post, we will learn about the different types of pagination like:

Offset-based pagination (Page based pagination)

The most traditional approach where you specify how many items to skip and how many to retrieve.

// API call example
GET /api/users?offset=20&limit=10

// or
GET /api/users?page=3&per_page=10

offset is the number of items to skip and limit is the number of items to retrieve.

Pros

Cons: Data can shift if new items appear (not stable for real-time feeds)

Use case: Admin dashboards, tables, lists.

Cursor-based pagination

A more modern approach where you specify a cursor (usually a timestamp or ID) instead of offset and retrieve items after that cursor.

// API call example
GET /api/users?cursor=1234567890
{
  "items": [...],
  "nextCursor": "cursorXYZ", // The cursor to get the next page
  "hasNext": true,
  "prevCursor": "cursor123" // The cursor to get the previous page
}

cursor is the pointer to start from.

Pros

Cons

Use case:

Summary