Pagy Show archive.org snapshot is a gem for pagination. They make some bold claims:
Pagy is the ultimate pagination gem that outperforms the others in each and every benchmark and comparison.
Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!
Maybe this is worth trying out.