@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,isFetchinganderrorproperties. -
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.