WebSQL is an old standard. And it is in my understanding that no libraries that have been developed during the past few years even considered using it as a backend. That is not without a reason, however, because WebSQL has been dead and removed from major browsers for a couple of years now, with IndexedDB doing much of the work in a more user friendly, object friendly interface.
However, when you deal with obscure libraries or existing legacy projects, or just need to provide long-term support, just because an API is deprecated, doesn't mean it doesn't work. If it ain't broke, don't fix it.
There are tons of libraries that depend on WebSQL, one of them being IndexedDBShim, providing a nice, functional, and fully tested IndexedDB in environments that don't have native IndexedDB. React native included.
React Native Expo-SQLite originally used a WebSQL interface. However, with the recent changes to Expo's API, the original Expo-SQLite API has been completely changed, designed similarly to Node-SQLite, providing fast, native code that no longer abstracts away SQLite underneath via a WebSQL-like layer.
However, with the main WebSQL backend in react native gone (Expo-SQLite/Legacy compatibility layer has been completely removed since SDK 52), some of my older projects that depended on IndexedDBShim would no longer work. And I just got contracted for another year of support.
So I had to look for inspiration. Luckily, there exists one code base where a WebSQL compatibility layer over a direct SQLite access library lives. And you guessed it, it's node WebSQL.
Using that as inspiration and with some assistance from coding aids to fill in boilerplates quickly, I finally got WebSQL back, working in React Native.
Just create a wrapper around the new SQLite library and use the returned openDatabase()
function as if you're back in 2020.
I hope the existence of this brings joy to all of you maintaining older codebases. Changing libraries is no fun 😅
Getting WebSQL back on React Native
Make Expo-SQLite/Legacy behaviour return to Expo SDK 52 and above.