ThimbleDB is deployable on an application's own domain. The package does not depend on a vendor-hosted service.
The root export contains:
ThimbleClientand browser cache/read primitivescreateThimbleClientandcreateThimbleConnection- typed collections, fluent bounded queries, and index definitions
- bounded mutation request, response, and limit types
ContentAddressedTrieEngineImmutableSnapshotEngine- TDB1 envelope encode/decode helpers
- ObjectStore and prefix/envelope wrappers
- trie and snapshot protocol types
- layout advisor types and
recommendCollectionLayout
Clients created from /api/config should pass collectionLayouts,
layoutGeneration, and configurationUrl into ThimbleClient. Mutations send
the generation header automatically, and stale clients clear caches and invoke
onLayoutChange before reading a retired layout.
The supported default is:
import { createThimbleClient } from "thimbledb";
const db = await createThimbleClient();For optional per-authority-and-scope IndexedDB limits:
const db = await createThimbleClient({
persistentCacheLimits: {
maxEntries: 128,
maxBytes: 4 * 1024 * 1024,
},
});PersistentCacheLimits and PersistentCacheMetrics are root-exported types.
Omitting the limits preserves existing persistence behaviour. Limits apply
only to the built-in adapter; combining them with disabled or custom
persistence is rejected. See Browser cache budgets for
accounting, diagnostics, measured cost, and offline limitations.
Typed collection:
const notes = defineCollection<Note>("notes", {
indexes: [
defineIndex<Note>(
"by-title",
["title"],
"equality",
{ include: ["lastModified"] },
),
],
});
const noteSummarySchema = {
parse(value: unknown): Pick<
Note,
"id" | "title" | "lastModified"
> {
return value as Pick<
Note,
"id" | "title" | "lastModified"
>;
},
};
const result = await db
.collection(notes)
.where((note) => note.title.eq("abc"))
.take(25)
.select(
["title", "lastModified"],
noteSummarySchema,
)
.get();Bounded mutation batch:
const result = await db.collection(notes).putMany([
{
id: "note-1",
title: "First",
lastModified: Date.now(),
},
{
id: "note-2",
title: "Second",
lastModified: Date.now(),
},
]);
console.log(result.revision);
console.log(result.documents);
console.log(result.cacheComplete);putMany() requires an authority that advertises mutation batching. It
accepts 1-20 unique document IDs in at most 1 MiB of JSON and publishes one
collection revision. cacheComplete reports whether every changed document
path was returned for immediate cache use; secondary-index pages still load
through the normal object path. The method does not silently fall back to
separate writes.
See Queries and secondary indexes.
Connections created by createThimbleClient() use an advertised bounded
point-read bundle endpoint on cold cache misses. They automatically retain the
individual object path for older or oversized deployments.
EnvelopeObjectStore and EnvelopeJsonObjectReader limit decoded objects to
16 MiB by default. Advanced direct integrations can provide an explicit
maximumDecodedBytes value. Raw encodeEnvelope() and decodeEnvelope()
calls accept the same optional bound.
The auth export contains:
AuthServiceAuthRepositoryOidcIdentityAdapterandcreateEntraAdapter- scope authorizer and rate-limiter implementations
- public identity, session, principal, and grant types
Credential policy, password recovery, verification, passkeys, and MFA remain the external provider's responsibility.
import { startNodeAuthority } from "thimbledb/authority/node";
await startNodeAuthority({
studio: true,
readBundles: true,
mutationBatches: true,
studioOrigin: "https://database.example.com",
collections: ["notes"],
collectionLayouts: {
notes: "snapshot",
},
collectionIndexes,
});The Node authority reads documented environment variables and serves the same authentication, object broker, key grant, write, deletion, linking, administration, retention, and layout-migration endpoints used by the reference deployment.
See In-app and separate authority deployment before choosing an in-app authority or a separately operated Worker or service.
Pass the optional onRequestDiagnostics callback for bounded request-local
store activity, selected phases, and CAS observations. It is disabled by
default and does not change response formats. See
Request-scoped authority diagnostics for payload
semantics, sink costs, delivery limits, and qualification.
import {
createCloudflareAuthority,
} from "thimbledb/authority/cloudflare";
export default createCloudflareAuthority({
studio: true,
readBundles: true,
mutationBatches: true,
studioOrigin: "https://database.example.com",
collections: ["notes"],
collectionLayouts: {
notes: "snapshot",
},
collectionIndexes,
});The Cloudflare authority uses caller-owned R2 and asset bindings. Routes, custom domains, buckets, OIDC applications, and secrets belong to the consumer's account.
The same optional onRequestDiagnostics callback is available here.
fetch(request, env, ctx) accepts an optional third execution context for
bounded best-effort background delivery; forward it when wrapping the
authority.
Both authority entry points and the type-only root API export
AuthorityRequestDiagnostics, RequestDiagnosticsHandler,
RequestOperationDiagnostics, RequestStoreDiagnostics, and
RequestPhaseDiagnostics. The Cloudflare and root APIs also export
RequestDiagnosticsExecutionContext.
import { LocalObjectStore } from "thimbledb/providers/local";The local entry point also exports PrefixObjectStore, CachedObjectStore,
and MeteredObjectStore. It has no cloud SDK dependency.
Use one LocalObjectStore instance per storage root. See the
local provider guide for replacement
semantics, reserved temporary-file names, permissions, and durability limits.
npm install @azure/storage-blobimport { AzureBlobObjectStore } from "thimbledb/providers/azure";The Azure SDK is an optional peer dependency and is loaded only when this
adapter or the Node authority's azure provider is used.
npm install @aws-sdk/client-s3import { S3ObjectStore } from "thimbledb/providers/s3";The AWS SDK is an optional peer dependency. The same adapter supports Amazon S3 and R2 through the S3 API.
The migration export contains:
- versioned archive manifest and NDJSON helpers
- JSON, CSV, and lowdb conversion
- SQLite migration support through Node's built-in SQLite API
- optional PostgreSQL and Firestore adapters
- Node migration command implementation
- programmatic secondary-index rebuild support
PostgreSQL requires optional pg. Firestore requires optional
@google-cloud/firestore.
See Logical migration.
Node authorities can serve the packaged Studio directly when studio: true.
Cloudflare and other static hosts can copy the same versioned assets:
npx thimbledb studio-assets .\<asset-directory>\studioSee ThimbleDB Studio.
With Studio enabled, Node and Cloudflare authorities expose
GET /api/studio/scopes/:scopeId/collections/:collection/export to an
authenticated session with a read grant for that scope.
The default response remains NDJSON. Add ?format=toon for an explicit,
bounded TOON download. Both formats exclude retained tombstones and include
the live record count and a SHA-256 checksum of the actual response body.
This HTTP option does not change package exports, typed query results,
storage, or the CLI archive format.
See Export format for headers, request examples, limits, rejection criteria, and the NDJSON escape hatch.
Generate a non-destructive Microsoft Entra authorization manifest fragment:
npx thimbledb generate-entra-roles --out entra-authorization.jsonThe output contains the recommended delegated scope and four application roles. See Machine and service access.
- Semantic versioning applies from package version
1.0.0. - TDB1 envelopes and committed protocol fixtures remain readable in every release that claims TDB1 compatibility.
- New optional object layouts may be added in a minor release.
- Removing or changing an exported symbol, authority endpoint, stored field, or required configuration value is a major-version change.
- Security fixes may reject malformed or legacy data that was never valid under the documented protocol.
Version 2 separates provider SDK installation from the base package. Azure, S3, and S3-compatible Node deployments must install their documented optional peer dependency.
- Node.js 22 or newer for the installed package and Node authority
- current and previous stable Chromium
- current and previous stable Firefox
- current and previous stable WebKit/Safari
- ESM only
Use a fully patched, maintained Node LTS release. Repository and generated-app
development need Node 22.12.0 or newer; the static website needs 22.23.4 or newer.
These tooling requirements do not raise the published library engine range.
The optional SQLite adapter needs Node's built-in node:sqlite API, available
without startup flags from Node 22.13.0. Optional provider SDKs may impose
their own Node requirements.
See development requirements and runtime qualification for the separate package, tooling and website checks.