How to efficiently implement pagination along with aggregation?

If I prefer composite aggregation, then for say Nth page, I need to query (n-1) times to get after_key value which is inefficient. Can someone please suggest efficient way to achieve the same?