In most cases you can use the StanadardSetController to handle pagination. It depends on the amount of data you are using. If it is less than 10,000 records at a time this works well. You create a SOQL query and store the results in the StandardSetControler on the server. Then you can use it's methods to paginate.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardsetcontroller.htm