@powersync/react
Interfaces
AdditionalOptions
Extends
HookWatchOptions
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
rawTableNames? | boolean | Deprecated All tables specified in tables will be watched, including PowerSync tables with prefixes. Allows for watching any SQL table by not removing PowerSync table name prefixes | HookWatchOptions.rawTableNames |
reportFetching? | boolean | - | HookWatchOptions.reportFetching |
runQueryOnce? | boolean | - | - |
streams? | QuerySyncStreamOptions [] | Experimental An optional array of sync streams (with names and parameters) backing the query. When set, useQuery will subscribe to those streams (and automatically handle unsubscribing from them, too). If QuerySyncStreamOptions is set on a stream, useQuery will remain in a loading state until that stream is marked as SyncSubscriptionDescription.hasSynced. This ensures the query is not missing rows that haven't been downloaded. Note however that after an initial sync, the query will not block itself while new rows are downloading. Instead, consistent sync snapshots will be made available as they've been processed by PowerSync. Sync streams are currently in alpha. | HookWatchOptions.streams |
tables? | string [] | - | HookWatchOptions.tables |
throttleMs? | number | The minimum interval between queries. | HookWatchOptions.throttleMs |
triggerImmediate? | boolean | Emits an empty result set immediately | HookWatchOptions.triggerImmediate |
UseSyncStreamOptions
A sync stream to subscribe to in useSyncStream.
For more details on sync streams, see the documentation.
Extends
SyncStreamSubscribeOptions
Properties
Property | Type | Description | Inherited from |
---|---|---|---|
name | string | The name of the stream to subscribe to. | - |
parameters? | Record <string , any > | Parameters for the stream subscription. A single stream can have multiple subscriptions with different parameter sets. | - |
priority? | 0 | 1 | 2 | 3 | A priority to assign to this subscription. This overrides the default priority that may have been set on streams. For details on priorities, see priotized sync. | SyncStreamSubscribeOptions.priority |
ttl? | number | A "time to live" for this stream subscription, in seconds. The TTL control when a stream gets evicted after not having an active SyncStreamSubscription object attached to it. | SyncStreamSubscribeOptions.ttl |
Type Aliases
SuspenseQueryResult<T>
type SuspenseQueryResult<T> = Pick<QueryResult<T>, "data" | "refresh">;
Type Parameters
Type Parameter |
---|
T |
Variables
PowerSyncContext
const PowerSyncContext: Context<AbstractPowerSyncDatabase>;
Functions
Function | Description |
---|---|
usePowerSync | Custom hook that provides access to the PowerSync context. |
- | |
- | |
- | |
useQuery | A hook to access the results of a watched query. |
useStatus | Custom hook that provides access to the current status of PowerSync. |
useSuspenseQuery | A hook to access the results of a watched query that suspends until the initial result has loaded. |
useSyncStream | Creates a PowerSync stream subscription. The subscription is kept alive as long as the React component calling this function. When it unmounts, SyncStreamSubscription.unsubscribe is called |
useWatchedQuerySubscription | A hook to access and subscribe to the results of an existing WatchedQuery instance. |
useWatchedQuerySuspenseSubscription | A hook to access and subscribe to the results of an existing WatchedQuery. |