Encrypted browser-first database for small web apps, backed by object storage with reusable Cloudflare and Node authorities
See the code
ThimbleDB
ThimbleDB is a Cloudflare-first database for small, read-heavy web applications. Browsers read encrypted immutable objects through an authenticated storage broker and retain them in memory and IndexedDB caches. Writes and key grants use the same small authority.
Cloudflare Workers and R2 are the reference deployment. Azure Blob Storage, Amazon S3, and a local filesystem adapter implement the same provider-neutral ObjectStore contract.
Licensed under the Apache License 2.0.
flowchart LR
subgraph Browser["Browser trust boundary"]
App["Web application"]
Client["ThimbleDB client"]
Memory["Decoded memory LRU"]
IDB["Device-key-encrypted IndexedDB"]
ScopeKey["Non-extractable scope key"]
App --> Client
Client --> Memory
Client --> IDB
Client --> ScopeKey
end
subgraph ReadPath["Brokered private-read boundary"]
Domain["Authenticated object endpoint"]
Objects["TDB1 gzip + AES-GCM envelopes"]
Domain --> Objects
end
subgraph Authority["Authenticated authority boundary"]
Auth["Authentication and scope authorisation"]
Grant["Short-lived key grant"]
Write["Validation and conditional write"]
Auth --> Grant
Auth --> Write
end
Client -- "Session-authorised ciphertext reads" --> Domain
Client -- "Mutations" --> Auth
Grant -- "Memory-only CryptoKey" --> ScopeKey
Write -- "Encrypted objects" --> Objects
flowchart TB
Engine["ThimbleDB protocol<br/>cache + scopes + TDB1 + conditional HEAD"]
Contract["ObjectStore abstraction<br/>get + put + delete + list + ETag conditions"]
Engine --> Contract
Contract --> R2["Cloudflare R2<br/>preferred"]
Contract --> Local["Local filesystem<br/>development"]
Contract --> Azure["Azure Blob Storage<br/>supported"]
Contract --> S3["Amazon S3<br/>supported"]
The stored object and encryption protocol stays the same across providers. Only bindings, credentials, and browser read authorisation differ.
The browser bundle is about 35.2 KB uncompressed and 10.1 KB gzip. It ships no database runtime or WASM module.
Install the package:
npm install thimbledb
The base install includes the browser/core APIs, authentication, Cloudflare authority, local provider, and Node authority without cloud storage SDKs. Install only the Node storage adapter your deployment uses:
# Azure Blob
npm install @azure/storage-blob
# Amazon S3 or R2 through the S3 API
npm install @aws-sdk/client-s3
Use the browser/core API from thimbledb, external identity primitives from
thimbledb/auth, and the complete endpoint authority from either
thimbledb/authority/node or thimbledb/authority/cloudflare. Consumers
supply their own domain, storage, OIDC application, and secrets.
Follow the full quickstart for Cloudflare, Node, and browser setup. Implementation prompts provide copy-paste instructions for coding tools.
Use Should you use ThimbleDB for a vibe-coded app? for an exact fit check before integration. The database comparisons describe when D1, SQLite, Firestore, lowdb, or direct object storage is the better choice.
See Use cases for workload fit checks and complete guides for personal workspaces, tenant operations, field use, catalogues, journals, and structured AI application context.
To run a source checkout:
npm install
npm run dev
Open http://127.0.0.1:5173.
Configure Entra or a generic OIDC provider before signing in. The browser harness accepts an API access token and exchanges it for a ThimbleDB session. See Authentication.
The local provider is intended for development and one Node process. It is not a multi-process coordination backend.
For the browser harness, sample store, and benchmark commands, see Evaluation harness.
The reference deployment uses:
Start with Deploy to Cloudflare.
Published evidence includes live multi-region browser results against a private Cloudflare Worker and R2 deployment:
evidence/r2-browser-multiregion-trie-2026-09-24.jsonevidence/r2-browser-multiregion-snapshot-2026-09-24.jsonThe measurements show:
These results do not establish better cost or latency than D1, Durable Objects, Turso, Firestore, or another managed database. See Benchmarks for methods, raw artifacts, limitations, and layout decision thresholds.
| Document | Purpose |
|---|---|
| Quickstart | Package, authority, browser client, and verification setup |
| Implementation prompts | Copy-paste integration, deployment, migration, and review prompts |
| npm publishing | OIDC trusted publisher setup and release process |
| Use cases | Fit criteria and application-specific guides |
| Architecture | Components, data flow, and scope model |
| System diagrams | Trust boundaries, sequences, keys, and providers |
| Storage providers | Provider abstraction and conformance requirements |
| Security | Threat model, encryption, keys, and revocation |
| Authentication | External identity mapping, sessions, and scope grants |
| Deletion and retention | Tombstones, restoration, scope erasure, and physical collection |
| Adaptive layouts | Snapshot/trie recommendations and explicit migration |
| Protocol | Binary envelope and object layout |
| Versioning | Package, protocol, key, and v1 compatibility rules |
| Public API | Stable package exports and authority integration |
| Evaluation harness | Browser harness, sample application, and benchmark usage |
| Benchmarks | R2 browser methodology, results, and limitations |
| Tradeoffs | Proven, expected, and unsuitable use cases |
| Cloudflare deployment | Worker and R2 reference deployment |
| Azure deployment | Container Apps and Blob Storage |
| AWS deployment | Lambda container and private S3 buckets |
| Operations | Keys, backup, metrics, incidents, and cleanup |
ThimbleDB is suited to small per-user or per-tenant datasets, catalogues, configuration, internal tools, and applications whose hot working set fits in browser storage.
Choose another database for relational transactions, high-frequency shared counters, large cross-tenant queries, or strict immediate revocation. Warm cached reads are fast, but cold object reads and external session creation can take seconds from distant regions. Design the first-load experience with those limits in mind.
28 commits
TypeScript
80.1%
CSS
7.5%
Astro
5.8%
JavaScript
3.9%
Bicep
1.5%
HTML
1.0%
Encrypted browser-first database for small web apps, backed by object storage with reusable Cloudflare and Node authorities
See the code
ThimbleDB
ThimbleDB is a Cloudflare-first database for small, read-heavy web applications. Browsers read encrypted immutable objects through an authenticated storage broker and retain them in memory and IndexedDB caches. Writes and key grants use the same small authority.
Cloudflare Workers and R2 are the reference deployment. Azure Blob Storage, Amazon S3, and a local filesystem adapter implement the same provider-neutral ObjectStore contract.
Licensed under the Apache License 2.0.
flowchart LR
subgraph Browser["Browser trust boundary"]
App["Web application"]
Client["ThimbleDB client"]
Memory["Decoded memory LRU"]
IDB["Device-key-encrypted IndexedDB"]
ScopeKey["Non-extractable scope key"]
App --> Client
Client --> Memory
Client --> IDB
Client --> ScopeKey
end
subgraph ReadPath["Brokered private-read boundary"]
Domain["Authenticated object endpoint"]
Objects["TDB1 gzip + AES-GCM envelopes"]
Domain --> Objects
end
subgraph Authority["Authenticated authority boundary"]
Auth["Authentication and scope authorisation"]
Grant["Short-lived key grant"]
Write["Validation and conditional write"]
Auth --> Grant
Auth --> Write
end
Client -- "Session-authorised ciphertext reads" --> Domain
Client -- "Mutations" --> Auth
Grant -- "Memory-only CryptoKey" --> ScopeKey
Write -- "Encrypted objects" --> Objects
flowchart TB
Engine["ThimbleDB protocol<br/>cache + scopes + TDB1 + conditional HEAD"]
Contract["ObjectStore abstraction<br/>get + put + delete + list + ETag conditions"]
Engine --> Contract
Contract --> R2["Cloudflare R2<br/>preferred"]
Contract --> Local["Local filesystem<br/>development"]
Contract --> Azure["Azure Blob Storage<br/>supported"]
Contract --> S3["Amazon S3<br/>supported"]
The stored object and encryption protocol stays the same across providers. Only bindings, credentials, and browser read authorisation differ.
The browser bundle is about 35.2 KB uncompressed and 10.1 KB gzip. It ships no database runtime or WASM module.
Install the package:
npm install thimbledb
The base install includes the browser/core APIs, authentication, Cloudflare authority, local provider, and Node authority without cloud storage SDKs. Install only the Node storage adapter your deployment uses:
# Azure Blob
npm install @azure/storage-blob
# Amazon S3 or R2 through the S3 API
npm install @aws-sdk/client-s3
Use the browser/core API from thimbledb, external identity primitives from
thimbledb/auth, and the complete endpoint authority from either
thimbledb/authority/node or thimbledb/authority/cloudflare. Consumers
supply their own domain, storage, OIDC application, and secrets.
Follow the full quickstart for Cloudflare, Node, and browser setup. Implementation prompts provide copy-paste instructions for coding tools.
Use Should you use ThimbleDB for a vibe-coded app? for an exact fit check before integration. The database comparisons describe when D1, SQLite, Firestore, lowdb, or direct object storage is the better choice.
See Use cases for workload fit checks and complete guides for personal workspaces, tenant operations, field use, catalogues, journals, and structured AI application context.
To run a source checkout:
npm install
npm run dev
Open http://127.0.0.1:5173.
Configure Entra or a generic OIDC provider before signing in. The browser harness accepts an API access token and exchanges it for a ThimbleDB session. See Authentication.
The local provider is intended for development and one Node process. It is not a multi-process coordination backend.
For the browser harness, sample store, and benchmark commands, see Evaluation harness.
The reference deployment uses:
Start with Deploy to Cloudflare.
Published evidence includes live multi-region browser results against a private Cloudflare Worker and R2 deployment:
evidence/r2-browser-multiregion-trie-2026-09-24.jsonevidence/r2-browser-multiregion-snapshot-2026-09-24.jsonThe measurements show:
These results do not establish better cost or latency than D1, Durable Objects, Turso, Firestore, or another managed database. See Benchmarks for methods, raw artifacts, limitations, and layout decision thresholds.
| Document | Purpose |
|---|---|
| Quickstart | Package, authority, browser client, and verification setup |
| Implementation prompts | Copy-paste integration, deployment, migration, and review prompts |
| npm publishing | OIDC trusted publisher setup and release process |
| Use cases | Fit criteria and application-specific guides |
| Architecture | Components, data flow, and scope model |
| System diagrams | Trust boundaries, sequences, keys, and providers |
| Storage providers | Provider abstraction and conformance requirements |
| Security | Threat model, encryption, keys, and revocation |
| Authentication | External identity mapping, sessions, and scope grants |
| Deletion and retention | Tombstones, restoration, scope erasure, and physical collection |
| Adaptive layouts | Snapshot/trie recommendations and explicit migration |
| Protocol | Binary envelope and object layout |
| Versioning | Package, protocol, key, and v1 compatibility rules |
| Public API | Stable package exports and authority integration |
| Evaluation harness | Browser harness, sample application, and benchmark usage |
| Benchmarks | R2 browser methodology, results, and limitations |
| Tradeoffs | Proven, expected, and unsuitable use cases |
| Cloudflare deployment | Worker and R2 reference deployment |
| Azure deployment | Container Apps and Blob Storage |
| AWS deployment | Lambda container and private S3 buckets |
| Operations | Keys, backup, metrics, incidents, and cleanup |
ThimbleDB is suited to small per-user or per-tenant datasets, catalogues, configuration, internal tools, and applications whose hot working set fits in browser storage.
Choose another database for relational transactions, high-frequency shared counters, large cross-tenant queries, or strict immediate revocation. Warm cached reads are fast, but cold object reads and external session creation can take seconds from distant regions. Design the first-load experience with those limits in mind.
28 commits
TypeScript
80.1%
CSS
7.5%
Astro
5.8%
JavaScript
3.9%
Bicep
1.5%
HTML
1.0%