README.md

@folio/client #

A persistent browser client for Folio's Rust engine. Built with wasm-pack; framework-independent TypeScript supplies IndexedDB, HTTP, and subscriptions.

import { openFolio } from "@folio/client";

const folio = await openFolio({
  did: "did:plc:...",
  // Supply authenticated fetch or a same-origin bridge for publication.
  fetch: authenticatedFetch,
});
const images = await folio.list("pics.pixl.image");
await folio.put(images[0].key, updatedImage);
await folio.sync();
await folio.close();

Reads, edits, and sync #

The first get or list loads a collection; after that, reads and edits work offline. Load a collection before editing it.

put and delete save to IndexedDB before resolving. Call sync to publish edits; a failed sync leaves them saved locally. close waits for pending operations before releasing resources.

subscribe(listener) notifies you of committed changes, including notifications from other tabs, and returns an unsubscribe function. Reread when the app resumes: tab notifications can be missed. Stored data and query caches are scoped by database name and DID.

Wasm setup #

Serve wasm/folio_bg.wasm with the application/wasm content type. The loader locates it relative to wasm/folio.js; your bundler must preserve or rewrite that URL. To load it yourself, pass wasm: fetch(wasmUrl) or Wasm bytes to openFolio.

Limits #

  • Browser-only storage; no Node adapter.
  • Public did:plc repositories only; no Space I/O.
  • Sync is explicit, with no background scheduler.
  • The client trusts the PDS; it does not verify repository signatures or proofs.
  • No offline photo or other blob storage.
  • Each commit checks the revision and replaces the entire serialized replica in one IndexedDB transaction. This is intended for small collections.
  • Browser quotas and eviction apply. Folio does not request persistent storage.

Development #

From the repository root, enter devenv shell, then run cargo make build or cargo make test. These commands do not publish packages.