Skip to content

feat(core,antd,mui): add cursor-based pagination support#7238

Open
jtomaszewski wants to merge 8 commits intorefinedev:mainfrom
jtomaszewski:vk/9986-add-cursor-based
Open

feat(core,antd,mui): add cursor-based pagination support#7238
jtomaszewski wants to merge 8 commits intorefinedev:mainfrom
jtomaszewski:vk/9986-add-cursor-based

Conversation

@jtomaszewski
Copy link

@jtomaszewski jtomaszewski commented Jan 29, 2026

Summary

  • Add cursor-based pagination support to useTable hook in core package
  • Add cursor pagination support to useDataGrid (MUI) and useTable (AntD) hooks
  • Add URL sync for cursor pagination with ?after=<cursor> and ?before=<cursor> params
  • Add "go to first page" navigation when cursor history is available
  • Add cursor pagination examples for both MUI and AntD

Changes

Core (@refinedev/core)

  • Extended useTable to support pagination.mode: "cursor"
  • Added cursor, hasNextPage, hasPreviousPage, goToNextPage, goToPreviousPage return values
  • Added URL sync support via syncWithLocation option
  • Data providers can return cursor: { next, prev } from getList

MUI (@refinedev/mui)

  • Extended useDataGrid with cursor pagination footer component
  • Uses useMemo with proper dependencies for re-rendering

AntD (@refinedev/antd)

  • Extended useTable with cursor pagination via table footer
  • Fixed re-render issue where buttons didn't update when hasNextPage/hasPreviousPage changed

Examples

  • table-material-ui-cursor-pagination: MUI DataGrid with GitHub commits API
  • table-antd-cursor-pagination: AntD Table with GitHub commits API

Test plan

  • Run MUI cursor pagination example and verify navigation works
  • Run AntD cursor pagination example and verify navigation works
  • Verify URL sync (?after=<cursor>) persists across page reloads
  • Verify "Previous" navigates back through cursor history
  • Run existing useTable tests

jtomaszewski and others added 7 commits January 28, 2026 14:27
- Add 'cursor' mode to Pagination.mode type
- Add CursorPagination interface for type safety
- Implement cursor state management with navigation history
- Add goToNextPage() and goToPreviousPage() navigation functions
- Add hasNextPage and hasPreviousPage computed properties
- Disable URL sync for cursor pagination mode (with warning)
- Pass cursor via meta.cursor.current to data provider
- Extract cursor from response (cursor.next, cursor.prev)
- Add comprehensive tests for cursor pagination

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update useDataGrid to expose cursor pagination helpers from core
- Simplify example to use pagination.mode: "cursor" instead of manual state
- Data provider now returns cursor in response (proper pattern)
- Add custom prev/next buttons since DataGrid doesn't support cursor natively

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add cursor param to URL via syncWithLocation
- Support bidirectional APIs (prefer API's prev cursor) with fallback to client history
- Auto-inject cursor pagination UI in MUI DataGrid via slots
- Auto-inject cursor pagination UI in AntD Table via itemRender
- Simplify MUI example to demonstrate automatic pagination

Users now just set `pagination: { mode: "cursor" }` and get automatic
prev/next buttons without manual component mounting.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use ?after=X or ?before=X instead of ?cursor=X for cursor pagination
- Add direction field to cursor state and meta for data providers
- Enable "go to first page" when landing on URL with cursor but no history
- Data providers receive meta.cursor.direction to know which API param to use

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When going back to the first page by clearing the cursor, explicitly
set after=undefined and before=undefined to remove them from the URL.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ender

Add table-antd-cursor-pagination example demonstrating cursor-based
pagination with AntD Table. Uses custom GitHub API data provider and
syncWithLocation for URL persistence.

Fix AntD cursor pagination buttons not updating when hasNextPage/
hasPreviousPage change by using useMemo with proper dependencies and
rendering pagination controls in table footer instead of itemRender.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jtomaszewski jtomaszewski requested a review from a team as a code owner January 29, 2026 21:57
@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

🦋 Changeset detected

Latest commit: ae9c18a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@refinedev/core Minor
@refinedev/antd Minor
@refinedev/mui Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant