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. Update: It can be turned back on. See “Update” below.
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.
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 an 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
Web Apps on Android: No problem – Chrome continues to support WebSQL.
Web Apps on iOS: Change the Web SQL setting in Safari, or make your app a native app. There is no known workaround for Home Screen apps at this time.
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
Update Sept 23, 2019
While SQLite is now disabled by default, it can be reenabled.
- Turn on the Developer’s menu. (Safari Prefs… Advanced)
- On the Developer’s menu, select Experimental Features. Uncheck ‘Disable Web SQL’
This works when running in Safari, but not for apps saved to the Home Screen. A bug report has been filed with Apple.
- Experimental Features
- Disable Web SQL (at the bottom)