Skip to content

Move connector snippets to the split connector API - #789

Draft
Chriztiaan wants to merge 4 commits into
docs/write-api-snippet-packagefrom
docs/connector-split
Draft

Chriztiaan wants to merge 4 commits into
docs/write-api-snippet-packagefrom
docs/connector-split

Conversation

@Chriztiaan

@Chriztiaan Chriztiaan commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Moves the connector snippets to the split connector API (Authenticator plus a mutation uploader), matching powersync-ja/powersync-reference-write-implementation#19.

-class MyBackendConnector extends PowerSyncBackendConnector {
-  fetchCredentials() { return { endpoint: '[Your PowerSync instance URL…]', token } }
-  uploadData(database) { … }
-}
+connect(db) {
+  authenticator = new MyAuthenticator()          // caches the token, cleared in invalidateCredentials()
+  db.connect({
+    powerSyncEndpoint: '[Your PowerSync instance URL…]',
+    authenticator,
+    upload: new MyBackendConnector({ authenticator }).upload
+  })
+}
  • Generic snippets: JavaScript, TypeScript, React Native, Dart, Kotlin, Swift. Rust already used the split API; only its caching comment changed.
  • Supabase snippets: the same six. Each connector is the Authenticator and exposes the upload. The Dart and Kotlin Supabase clients can return an expired token, so those snippets refresh the session when it has expired or is about to.
  • Every Authenticator caches its token, because the SDK isn't guaranteed to cache it.
  • The instance URL placeholder moves into each generic snippet's connect() call. The placeholder text is unchanged, so the Dashboard's replacement still works.
  • Pages: Reference Write Implementation and Supabase Edge Function ("Connect Your App"), and the Backend Connector Examples intro.
  • .NET stays on IPowerSyncBackendConnector until a stable .NET release supports the split API.

AI Disclosure

Use Claude Opus 5.5 to help wrangle this.

Todo

Each generic and Supabase connector snippet, except .NET, now connects
with an Authenticator and a mutation uploader instead of a
PowerSyncBackendConnector. Each Authenticator caches its token and clears
it in invalidateCredentials(), because the SDK isn't guaranteed to cache
tokens. The generic snippets put the instance URL placeholder in their
connect() call.

The reference write implementation and Supabase Edge Function pages now
connect the reference connector with an Authenticator, matching
powersync-reference-write-implementation#19.

.NET stays on IPowerSyncBackendConnector until a stable .NET SDK release
supports the split API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant