Careful that this library last I used it (2020 or so) used a particularly insecure encoding of the cursor that basically allows remote execution. Not sure if they ever addressed it.
Here's the fork I created at the time to work around some of these issues: https://github.com/1player/paginator