The future of SQLite

Apple has announced that the next version of Safari will no longer support SQLite. This has been confirmed in the beta of iOS 13 – it’s gone.

There’s no need to panic. There are workarounds, which I’ll get to later in this post. Also, there are no indications that Google will do the same with Chrome.

Some History

SQLite was introduced into browsers many years ago as WebSQL. It was a great idea: SQLite is small, powerful and solid. You can make great apps with it. The problem came from the standards committee. W3C prefers a clear standard with alternative implementations: saying “Just use SQLite” isn’t good enough. They decided, in 2009, to deprecate WebSQL and replace it with IndexedDB.

(Behind the scenes, I hear there were some heavy politics going on. Microsoft and Oracle were both very unhappy with WebSQL using SQLite – they each had their own established database software and did not want an upstart competitor to become standard.)

Regardless, Safari and Google continued to include WebSQL in their browsers. FireFox and IE did not. https://caniuse.com/#search=websql

The suggested replacement, IndexedDB, is not a SQL database. It’s more of an indexed file system. It’s been criticized for being slow, clumsy and inconsistently implemented. For more information, see this article: https://developers.google.com/web/ilt/pwa/working-with-indexeddb

Alternatives

Web Apps on Android: No problem – Chrome continues to support WebSQL.

Web Apps on iOS: Either use Chrome to run your app, or make your app a native app.

Native Apps for iOS and Android: Use the PhoneGap plugin for SQLite (as you probably have been). Just as this to your config.xml – no changes to your code.

<plugin name="cordova-sqlite-evcore-extbuild-free" source="npm" />

Desktop Apps: Another reason to use Electron. Use the SQLite plugin https://www.npmjs.com/package/sqlite