Skip to main content

PowerSyncBackendConnector

Properties

PropertyTypeDescription
fetchCredentials() => Promise<PowerSyncCredentials | null>Allows the PowerSync client to retrieve an authentication token from your backend which is used to authenticate against the PowerSync service. This should always fetch a fresh set of credentials - don't use cached values. Return null if the user is not signed in. Throw an error if credentials cannot be fetched due to a network error or other temporary error. This token is kept for the duration of a sync connection.
uploadData(database) => Promise<void>Upload local changes to the app backend. Use CommonPowerSyncDatabase.getCrudBatch to get a batch of changes to upload. Any thrown errors will result in a retry after the configured wait period (default: 5 seconds).

Methods

postCheckpointRequest()?

optional postCheckpointRequest(clientId, requestId): Promise<string>;

Posts a client-generated checkpoint request to the backend and returns the effective checkpoint request state.

This method is optional. It only needs to be implemented when the selected CheckpointMode is requests and asynchronous backend uploads are used. In any other case, this method should not be present on backend connectors.

Parameters

ParameterTypeDescription
clientIdstringThe PowerSync client ID for the current device.
requestIdstringThe client-generated checkpoint request ID (a positive 64-bit integer encoded as a string).

Returns

Promise<string>