Cana — Usage Guide
Focused guide hub for @jumentix/cana.
Cana is a framework-agnostic IndexedDB client for any browser frontend. Use it when an application needs durable offline data, explicit IndexedDB transactions, change events, optional worker isolation, and a clear bridge to whatever UI store you already use (vanilla state, React Context, Redux, Pinia, or another library).
It was built for Jumentix, but the public API has no framework dependency — only the browser.
This page is intentionally short. The full guide is split into smaller pages so each topic can show complete code without turning one document into a wall.
Choose the next step
- Getting started — install Cana, create the
categoriesandtaskstables, seed data, and read it back. - Integrate with any framework — the wiring pattern for any UI store.
- Vanilla TypeScript — same task app without a framework.
- Schema and keys — versioned schema changes, inbound keys, generated keys, outbound keys and validation.
- Reading, writing and bulk operations —
get,add,put,update,delete,clear,bulkAdd,bulkPutand predictable failure handling. - Querying and plans — indexes,
equals,limit,offset,count,explain()and complexity. - Transactions and change events — atomic writes,
CanaChangeEvent, replay windows and UI store synchronization. - Hooks and errors —
beforeWrite,afterCommit,CanaErrorguards and common recovery branches. - Storage and crash recovery — storage assessment,
durability assessment, export/import and
resolveWrite(). - Workers and testing —
createWorkerHost(),createRouter(),createWorkerClient()and test strategy. - API reference — compact method map and glossary.
The running example
Every page uses the same small task system. There are two stores:
| Store | Purpose | Main fields |
|---|---|---|
categories | Groups tasks by work area. | id, name, color, createdAt, updatedAt |
tasks | Durable task records. | id, title, categoryId, completed, priority, createdAt, updatedAt |
The examples keep framework state outside Cana. Cana owns persistence and
committed events; your UI store (vanilla Map, Context, Redux, Pinia, …)
owns rendering state.
Complete code policy
The code blocks in these pages are written as copyable implementation units. When a snippet is executable in the website, the page includes a Run playground. When a snippet needs a real application boundary, such as a dedicated Worker file, the page shows every file involved instead of hiding the missing parts behind placeholders.
Use with any UI framework
- Integrate with any framework — the stable contract and five-step wiring pattern.
- Vanilla TypeScript tutorial — no framework helpers, DOM/
Mapstate. - React Context API
- React Redux
- Vue 3 and Pinia
Optional helpers (@jumentix/cana-react, @jumentix/cana-vue) only patch framework state for you; they are not required.
Package integrations
Use the small integration packages when you want Cana events to patch framework state directly:
bun add @jumentix/cana @jumentix/cana-react
bun add @jumentix/cana @jumentix/cana-vue