Search code examples
javascriptiosindexeddbincognito-modedexie

Dexie/IndexedDB mobile Private Browsing Error - Uh oh: Missing API Error: IndexedDB API Not Available


I am receiving the error when trying to load my web app on iOS Safari and iOS Chrome. No errors on private browsing on desktop.

I added the following:

if (window.indexedDB) {
  console.log('IDB supported');
  var db = new Dexie('Stir');
  //Dexie stuff
}

Using the Safari dev tools, "IDB supported" is being logged - but then the error/alert pops up and is impeding actions.

I have all of my dexie code wrapped inside if (window.indexedDB) - to make sure it is only run if IDB is available in the browser.

My full repo is available at https://github.com/georgecook92/Stir. If looking at this code, the calls to dexie are in the actions index.js and the main index.js for React.


Solution

  • Dexie can throw that error when the call to indexedDB.open (dB name, version) returns null. A null check was added in the dexie source code in response to the following issue:

    https://github.com/dfahlander/Dexie.js/issues/134.

    Maybe it would cause less confusion if another error had been used to distinguish it from the real absence of window.indexedDB.

    Only Safari has the behavior to ever return null from indexedDB.open (). Reason you see it on ios chrome is because that browser runs on safari underhood due to Apple's license restrictions that forbids any other browser engine else than Safari to run on ios.