Quickstart
Install Store and create your first local-first store in under five minutes.
Install the SDK
Add the TypeScript client to your project using your preferred package manager:
npm install @cuitty/store/client
# or
bun add @cuitty/store/client
Create a client
createStore creates a local-first client for one module. The profile selects adapters and sync policy, while the schema names the storage classes your app will use.
import { createStore } from "@cuitty/store/client";
const store = await createStore({
module: "my-app",
profile: {
id: "local-dev",
name: "Local Dev",
local: { adapter: "local.sqlite", path: ".cuitty/store/dev.sqlite" },
remotes: [],
routes: [],
encryption: { atRest: "disabled", remote: "disabled", p2p: "disabled" },
sync: { mode: "manual" },
},
schema: {
users: { class: "record" },
},
actorId: "device:local",
});
Write and read a record
Records are key-value documents. Each record has a string key and a JSON-serializable value. Store records every write in the operation log for local-first sync and migration workflows.
const users = store.record("users");
await users.put("user:1", {
name: "Alice",
email: "alice@example.com",
plan: "pro",
});
const user = await users.get("user:1");
console.log(user?.name); // "Alice"
Flush sync
Store queues writes locally. Manual sync profiles flush queued operations when you ask them to.
const status = await store.sync.flush();
console.log(status.pending); // 0
For continuous or multi-device sync, add remote targets and route rules to the profile. See Sync Engine and the Adapter Matrix.
Next steps
- Learn about the four store classes (records, events, blobs, kv)
- Explore available adapters for different backends
- Set up P2P sync for direct device-to-device replication