Core API

createDB()

The core factory function that opens an IndexedDB connection and creates typed Store instances.

Usage

createDB() is the framework-agnostic entry point. It takes a DatabaseConfig object and returns a Database instance with typed store accessors.

database.ts

DatabaseConfig

The configuration object passed to createDB().

NameTypeDescription
name *stringName of the IndexedDB database
version *numberSchema version — increment when changing stores/indexes
stores *DBSchemaObject mapping store names to their configuration
ssr SSRStrategyHow to handle server-side calls (default: 'noop')
onUpgrade functionCustom migration callback for onupgradeneeded
onBlocked functionCalled when another tab blocks version change
debug booleanEnable console logging for all operations (default: false)

StoreConfig

Configuration for each object store.

NameTypeDescription
keyPath *stringThe property used as the primary key
autoIncrement booleanAuto-generate keys when not provided (default: false)
indexes Record<string, IndexConfig>Secondary indexes for querying

IndexConfig

Configuration for secondary indexes on a store.

NameTypeDescription
keyPath *string | string[]The property (or properties) to index
unique booleanWhether indexed values must be unique (default: false)
multiEntry booleanIf keyPath is an array value, index each element (default: false)

Database methods

The returned Database object provides these utility methods in addition to the typed store accessors.

NameTypeDescription
getRawDB() Promise<IDBDatabase>Get the underlying native IDBDatabase instance
close() Promise<void>Close the database connection