usePowerSync()
function usePowerSync(key): Ref<AbstractPowerSyncDatabase>
Retrieve 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.
If the key parameter is provided, the nearest client under that key will be retrieved.
Parameters
Parameter | Type | Default value |
---|---|---|
key | string | undefined |
Returns
Ref
<AbstractPowerSyncDatabase
>
The PowerSync client if found, otherwise undefined.