Skip to main content

@powersync/vue

Interfaces

AdditionalOptions<RowType>

Extends

  • Omit<SQLOnChangeOptions, "signal">

Type Parameters

Type ParameterDefault type
RowTypeunknown

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 prefixesOmit.rawTableNames
reportFetching?booleanIf true (default) the watched query will update its state to report on the fetching state of the query. Setting to false reduces the number of state changes if the fetch status is not relevant to the consumer.-
rowComparator?DifferentialWatchedQueryComparator<RowType>Used to compare query result sets. By default the hook will requery on any dependent table change. This will emit a new hook result even if the result set has not changed. Specifying a DifferentialWatchedQueryComparator will remove emissions for unchanged result sets. Furthermore, emitted data arrays will preserve object references between result set emissions for unchanged rows. Example { rowComparator: { keyBy: (item) => item.id, compareBy: (item) => JSON.stringify(item) } }-
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.-
tables?string[]-Omit.tables
throttleMs?numberThe minimum interval between queries.Omit.throttleMs
triggerImmediate?booleanEmits an empty result set immediatelyOmit.triggerImmediate

Functions

FunctionDescription
createPowerSyncPluginCreate a Vue plugin to define the PowerSync client. Client will be provided app-wide (highest position in component hierarchy).
providePowerSyncProvide the PowerSync client for all the caller component's descendants. This function works on a hierarchical basis, meaning that the client provided by providePowerSync in a child component will override the client provided by createPowerSyncPlugin in a parent component. If createPowerSyncPlugin was used to provide an app-wide client, all providePowerSync invocations are below it in the hierarchy.
usePowerSyncRetrieve the nearest PowerSync client from the component hierarchy. The client can be provided by using the createPowerSyncPlugin function to provide an app-wide client or by using the providePowerSync function in an ancestor component. If multiple clients are found in the hierarchy, the closest client to the current component will be used.
usePowerSyncQuery-
usePowerSyncStatus-
usePowerSyncWatchedQuery-
useQueryA composable to access the results of a watched query.
useStatusRetrieve the current synchronization status of PowerSync.
useSyncStreamCreates a PowerSync stream subscription. The subscription is kept alive as long as the Vue component calling this function is mounted. When it unmounts, SyncStreamSubscription.unsubscribe is called
useWatchedQuerySubscriptionA composable to access and subscribe to the results of an existing WatchedQuery instance.