Connect SDK

Connect SDK

Use the Connect SDK to authorize a collection and call typed mdbase operations.

@mdbase/connect is the browser and native-shell SDK for applications that operate on one user-approved local or hosted mdbase collection. The application asks for exact operations. Connect selects the route and the collection authority checks the current grant.

Choose the first result you need

Learn the collection API

Run typed reads and revision-safe changes against an in-memory collection. This path needs no account or running service.

Try the SDK locally
Connect a real application

Add a manifest, authorize one compatible collection, complete the browser callback, and use the approved connection.

Open the Connect guide
Private-beta release status

The production service and protocol 1 are deployed for beta accounts. The npm packages await their first public release. Current developers build or pack the versioned artifacts from theConnect repository.

SDK surfaces

SurfaceUse it forDepends on
MdbaseConnectApplication-level manager for web, native-shell, and portable-file authorizationBrowser APIs or adapters supplied by a native shell
MdbaseConnectionOne collection's operations, renewal, routing, notifications, and provider-neutral syncBrowser APIs or adapters supplied by a native shell
MdbaseBrowserLocationBookmarkable collection selection, authorization return URLs, and browser navigationA stable MdbaseConnect manager and browser history APIs
MdbaseCollectionClientDomain and feature logic that should be independent of OAuth and hostingA small MdbaseCollectionTransport
createSandbox()Fast frontend tests for CRUD, revisions, pagination, defaults, and change cursors@mdbase/connect-dev
OfflineReplicaOffline-first applications backed by any sync-capable authority@mdbase/connect-sync

Application structure

Create one MdbaseConnect manager at the application boundary. Pair it with one MdbaseBrowserLocation at the browser application boundary. Resolve its active connection, then pass that MdbaseConnection into feature code. The location helper owns bookmark selection and OAuth return cleanup; the manager owns saved authorizations. A bound connection never changes collections underneath a repository, and feature code written against MdbaseCollectionClient can also run against the developer sandbox or another conforming transport.

A downloaded HTML file supplies distribution: "portable" in its inline manifest. The same manager then uses short-code approval and session-only credentials. See the portable HTML application guide.

tasks.ts
import type { MdbaseCollectionClient } from "@mdbase/connect";

export async function listOpenTasks(client: MdbaseCollectionClient<Task>) {
  return client.queryAll({
    types: ["task"],
    where: 'status == "open"',
    order_by: [{ field: "due", direction: "asc" }]
  });
}
The operation envelope is part of the contract.

Record operations return { valid, result, diagnostics }. Use unwrapOperation() when exceptions suit the calling code, or inspect the envelope when the interface should present validation diagnostics inline.

Package map

PackagePurpose
@mdbase/connectAuthorization, routes, operations, notifications, and authority-neutral sync handoff
@mdbase/connect-devManifest validation, contract validation, and deterministic sandbox transport
@mdbase/connect-protocolShared TypeScript types and canonical JSON Schemas
@mdbase/connect-syncAuthority-neutral replication state machine, IndexedDB replica, conflicts, and offline mutations
@mdbase/connect-webhooksServer-side verification for signed notification webhooks