Skip to main content

@powersync/react

Interfaces

AdditionalOptions

Extends

  • HookWatchOptions

Properties

PropertyTypeDescriptionInherited from
rawTableNames?booleanDeprecated 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 prefixesHookWatchOptions.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?numberThe minimum interval between queries.HookWatchOptions.throttleMs
triggerImmediate?booleanEmits an empty result set immediatelyHookWatchOptions.triggerImmediate

UseSyncStreamOptions

A sync stream to subscribe to in useSyncStream.

For more details on sync streams, see the documentation.

Extends

  • SyncStreamSubscribeOptions

Properties

PropertyTypeDescriptionInherited from
namestringThe 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 | 3A 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?numberA "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

FunctionDescription
usePowerSyncCustom hook that provides access to the PowerSync context.
usePowerSyncQuery-
usePowerSyncStatus-
usePowerSyncWatchedQuery-
useQueryA hook to access the results of a watched query.
useStatusCustom hook that provides access to the current status of PowerSync.
useSuspenseQueryA hook to access the results of a watched query that suspends until the initial result has loaded.
useSyncStreamCreates 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
useWatchedQuerySubscriptionA hook to access and subscribe to the results of an existing WatchedQuery instance.
useWatchedQuerySuspenseSubscriptionA hook to access and subscribe to the results of an existing WatchedQuery.