How to Implement Cursor-Based Pagination with Neo4j and React

Hello everyone,

I'm currently working on a project where I'm using Neo4j as my database backend and React for my frontend. I've been using traditional skip-limit pagination to fetch data, but I've noticed some performance issues, especially with large datasets. After some research, I came across the concept of cursor-based pagination, and I'm interested in implementing it in my application.

I understand the basic idea behind cursor-based pagination, where the server sends a cursor/token along with the data to the client, allowing for more efficient navigation through the dataset. However, I'm not sure how to implement this in the context of Neo4j and React.

Specifically, I'm looking for guidance on the following:

How do I modify my Cypher queries in Neo4j to support cursor-based pagination?
How do I handle cursors/tokens in my React frontend to fetch the next page of results?
Are there any best practices or libraries/frameworks that I should be aware of when implementing cursor-based pagination with Neo4j and React?

I would appreciate any advice, examples, or resources that you can provide to help me implement cursor-based pagination in my application. Thank you in advance for your help!

Not out of the box,
what you can use is to have an indexed ordering key and use that as your cursor
(or use elementId/id) alternatively you can use the reactive async driver with backpressure to retrieve a stream of values.

MATCH (p:Person)
WHERE p.email > $cursor
...
RETURN p
ORDER BY p.email ASC LIMIT 100