Vaadin 8 Grid pagination

I have millions of rows in DB, which I want to show inside the grid component using pagination control. For example, 100 rows per page. The problem is when you set a data provider, rows are continuously added on grid scrolling, and you can’t control the limit and offset - it will fill the grid with all rows eventually. What’s the best design pattern to implement pagination using data provider and have sorting working from within backend? (when setting items with grid.setItems(), sorting is performed in memory, and I need to be done in backend).

Take a look at this :!addon/pagination

and this :

Look at Sorting section.

Thanks. The pagination addon solves my problem.

Pagination is more or less built in in Vaadin 8 grids: