@powersync/react package provides React hooks for use with the JavaScript Web SDK or React Native SDK. These hooks are designed to support reactivity, and can be used to automatically re-render React components when query results update or to access PowerSync connectivity status changes.
npm: @powersync/react
useQuery: This allows you to access the results of a watched query. The response includesisLoading,isFetching,fetchReasonanderrorproperties. WhileisFetchingis true,fetchReasonis'initial','refresh'(after callingrefresh()on arunQueryOncequery),'tables-changed'or'settings-changed'.'settings-changed'means the SQL, parameters or options changed, anddatastill holds the previous query’s rows until the updated query returns its first result.fetchReasonrequires@powersync/react2.1.0 or later.useStatus: Access the PowerSync connectivity status. This can be used to update the UI based on whether the client is connected or not.useSuspenseQuery: This hook also allows you to access the results of a watched query, but its loading and fetching states are handled through Suspense. It automatically converts certain loading/fetching states into Suspense signals, triggering Suspense boundaries in parent components.
For advanced watch query features like incremental updates and differential results for React Hooks, see Live Queries / Watch Queries.