Skip to main content
There are a few ways to accomplish infinite scrolling with PowerSync, either by querying data from the local SQLite database, or by lazy-loading or lazy-syncing data from your backend. Here is an overview of the different options with pros and cons:

1) Pre-sync all data and query the local database

PowerSync currently performs well with syncing up to 1,000,000 rows per client. This means that in many cases, you can sync a sufficient amount of data to let a user keep scrolling a list or feed that basically feels “infinite” to them.

2) Control data sync using subscription or client parameters

Sync Streams (recommended): Use subscription parameters to subscribe to specific data on demand. For example, a client can subscribe to a specific “page” of data when the user scrolls to it. This is more flexible than client parameters — each subscription is independent and multiple tabs/views can subscribe with different parameters simultaneously. Sync Rules (legacy): PowerSync supports the use of client parameters which are specified directly by the client. The app can dynamically change these parameters on the client-side and they can be accessed in Sync Rules on the server-side. The developer can use these parameters to limit/control which data is synced, but since they are not trusted (because they are not passed via the JWT authentication token) they should not be used for access control. You should still filter data by e.g. user ID for access control purposes (using token parameters from the JWT). Usage example: To lazy-load/lazy-sync data for infinite scrolling, you could split your data into ‘pages’ and use a subscription parameter (Sync Streams) or client parameter (Sync Rules) to specify which pages to sync to a user.

3) Sync limited data and then load more data from an API

In this scenario we can sync a smaller number of rows to the user initially. If the user reaches the end of the page/feed/list, we make an online API call to load additional data from the backend to display to the user.

4) Client-side triggers a server-side function to flag data to sync

You could add a flag to certain records in your backend source database which are used by your Sync Streams or Sync Rules to determine which records to sync to specific users. Then your app could make an API call which triggers a function that updates the flags on certain records, causing more records to be synced to the user.

Questions?

Ask on Discord if you need help implementing infinite scrolling.