createReactiveDB()
The Svelte 5 reactive wrapper that adds live queries to every store.
Overview
createReactiveDB() wraps createDB() and returns a ReactiveDatabase where every store is a ReactiveStore with liveAll(), liveGet(), and liveCount() methods. These live queries use Svelte 5 $state runes under the hood, so your UI updates automatically when data changes.
Usage
+page.svelte
ReactiveDatabase type
The returned type extends the base Database with reactive stores and a liveQuery() method.
| Name | Type | Description |
|---|---|---|
[storeName] | ReactiveStore<T> | Each store from your schema becomes a ReactiveStore |
getRawDB() | Promise<IDBDatabase> | Access the underlying IndexedDB instance |
close() | Promise<void> | Close the database connection |
liveQuery(fn, stores) | ILiveQuery<T> | Create a custom live query across multiple stores |
Custom live queries
Use liveQuery() for complex queries that span multiple stores or need custom logic.
custom-query.svelte