Pagination: number of elements per page depending on viewport size

As already summarized in the title: is there a way to set the number of elements per page depending on the size of the viewport?

Example:
default: 30 elements per page
min-width 50rem: 50 elements per page
min-width 75rem: 100 elements per page

I already did some research, setting values dynamically depending on the size of the viewport seems to be a bigger deal in PHP, at least for my limited understanding… but maybe there is an elegant Kirby solution…?

The viewport is something that is known only on the client side (the browser), while Kirby as a PHP application operates on the server.

While the browser sends certain data about itself to the server when a request is made, the viewport is not part of this information and the viewport can be changed any time in the browser without making a new request.

Having said that, you can of course make a new request to the server every time the user change their viewport, but that would also mean a waste of resources.

Another option would be to use a library like mobile detect which works server-side by analyzing the request data. This is based on device rather than actual viewport. There is a Kirby plugin that is a wrapper around this library: Mobile Detect | Kirby CMS

Yet another option would involve the user of cookies.

Thank you very much, this coincides with my research. Using a library or cookies is not proportional to the benefit for my current project. I will leave it at an average that works as a good compromise for all viewport sizes. Nevertheless - thanks a lot for your support.