Skip to content

SSR, frameworks and tests ​

SSR ​

With Next.js, Nuxt, SvelteKit or Astro, importing doxor and calling createDB() on the server is safe: nothing runs until the first operation. Run operations in client-only code, such as effects and event handlers. On the server they reject with the code Unavailable.

Vue and MobX ​

Reactive proxies cannot be stored in IndexedDB. Store plain data instead: db.todos.put(toRaw(todo)), or structuredClone(toRaw(todo)) for nested objects.

Persistence ​

Browsers may evict site data under storage pressure. Call navigator.storage.persist() to ask for durable storage.

Tests ​

doxor works with fake-indexeddb in Node. Either install it as a global, or pass an implementation to createDB():

ts
import 'fake-indexeddb/auto' // installs a global indexedDB
// or inject an implementation explicitly:
import { 
IDBFactory
,
IDBKeyRange
} from 'fake-indexeddb'
const
db
=
createDB
({
name
: 'test',
collections
,
indexedDB
: new
IDBFactory
(),
IDBKeyRange
})

Passing an implementation gives each test its own isolated database factory.

Released under the MIT License.