Persist
Persist Quickstart
Install the Persist SDK and create your first store in under a minute.
Persist Quickstart
Install
# npm
npm install @cuitty/persist
# bun
bun add @cuitty/persist
# pnpm
pnpm add @cuitty/persist
Create a store
import { createStore } from "@cuitty/persist";
const store = await createStore({
name: "my-app",
adapter: "sqlite",
path: "./data/my-app.db",
});
Basic CRUD
// Put a record
await store.records.put("users/alice", {
name: "Alice",
role: "admin",
});
// Get a record
const alice = await store.records.get("users/alice");
// List records by prefix
const users = await store.records.list("users/");
// Delete a record
await store.records.delete("users/alice");
Enable sync
Add a sync block to push local writes to a remote backend automatically. Writes never block โ sync runs in the background.
const store = await createStore({
name: "my-app",
adapter: "sqlite",
path: "./data/my-app.db",
sync: {
remote: "postgres",
strategy: "last-write-wins",
},
});
See Sync & Conflict Resolution for strategies and conflict handling.
Enable encryption
Set encrypt: true to encrypt all data before it leaves the device. The sync server never sees plaintext.
const store = await createStore({
name: "my-app",
adapter: "sqlite",
path: "./data/my-app.db",
encrypt: true,
sync: {
remote: "postgres",
strategy: "last-write-wins",
},
});
See End-to-End Encryption for key management and zero-knowledge architecture.