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 :
https://vaadin.com/directory#!addon/pagination

and this :
https://vaadin.com/docs/-/part/framework/datamodel/datamodel-providers.html#datamodel.dataproviders.lazy

Look at Sorting section.

Thanks. The pagination addon solves my problem.

Pagination is more or less built in in Vaadin 8 grids: https://vaadin.com/blog/lazy-loading-with-vaadin-8