PowerSync SDK on NuGet
This SDK is distributed via NuGet [External link].
Source Code
Refer to the powersync-dotnet repo on GitHub.
API Reference (Coming soon)
A full API Reference for this SDK is not yet available. This is planned for a future release.
Example Projects
Gallery of .NET example projects/demo apps built with PowerSync.
This SDK is currently in an alpha release. It is not suitable for production use as breaking changes may still occur.
Supported Frameworks and Targets
The PowerSync .NET SDK supports:- .NET Versions: 6, 8, and 9
- .NET Framework: Version 4.8 (requires additional configuration)
- MAUI: Cross-platform support for Android, iOS, and Windows
- WPF: Windows desktop applications
- Blazor (web) platforms are not yet supported.
SDK Features
- Provides real-time streaming of database changes.
- Offers direct access to the SQLite database, enabling the use of SQL on both client and server sides.
- Enables subscription to queries for receiving live updates.
- Eliminates the need for client-side database migrations as these are managed automatically.
Quickstart
For desktop/server/binary use-cases and WPF, add the
PowerSync.Common
NuGet package to your project:Add
--prerelease
while this package is in alpha.- Signed up for a PowerSync Cloud account (here) or self-host PowerSync.
- Configured your backend database and connected it to your PowerSync instance.
1. Define the schema
The first step is defining the schema for the local SQLite database. This schema represents a “view” of the downloaded data. No migrations are required — the schema is applied directly when the local PowerSync database is constructed (as we’ll show in the next step). You can use this example as a reference when defining your schema.2. Instantiate the PowerSync Database
Next, you need to instantiate the PowerSync database — this is the core managed database. Its primary functions are to record all changes in the local database, whether online or offline. In addition, it automatically uploads changes to your app backend when connected. Example: The initialization syntax differs slightly between the Common and MAUI SDKs:3. Integrate with your Backend
The PowerSync backend connector provides the connection between your application backend and the PowerSync client-side managed SQLite database. It is used to:- Retrieve an auth token to connect to the PowerSync instance.
- Apply local changes on your backend application server (and from there, to your backend database)
- PowerSyncBackendConnector.FetchCredentials - This is called every couple of minutes and is used to obtain credentials for your app backend API. -> See Authentication Setup for instructions on how the credentials should be generated.
- PowerSyncBackendConnector.UploadData - Use this to upload client-side changes to your app backend. -> See Writing Client Changes for considerations on the app backend implementation.
connect
to start the synchronization process:
Usage
After connecting the client database, it is ready to be used. You can run queries and make updates as follows:Configure Logging
Enable logging to help you debug your app. By default, the SDK uses a no-op logger that doesn’t output any logs. To enable logging, you can configure a custom logger using .NET’sILogger
interface: