SQLite 3.40.0 has been made available with official Wasm compilation support.

Web developers can now utilize SQL to query local databases with the help of the browser’s local storage, session storage and OPFS (Origin-Private FileSystem). The supporting system, however, is still patchy.

The developers of SQLite claim that, as of now, only the most recent versions of Chromium-based browsers will have the required APIs. Another limitation is that Wasm support for SQLite is in beta, even though it’s supposed to be finished in the upcoming version.

Impact

Developers familiar with Web SQL, a browser-based SQLite implementation created in 2009 but dropped as a standard in 2010, may feel like they’ve seen this before.

The specification came to a standstill because all interested implementers used the same SQL backend (SQLite) while standardization requires numerous independent implementations.

The result was the deprecation of Web SQL, while the need from developers for SQL queries to local storage remained unfulfilled. This issue is resolved with SQLite being compiled to Wasm, as it will now be downloadable as an application component instead of being included with browsers.

SQL in browser APIs

Given that richer web applications are becoming the norm, having SQL in the browser API makes sense. SQL is the industry standard for handling relational data.

Although it doesn’t directly compete with products like Oracle or SQL Server, the open-source SQL database engine SQLite is incorporated in several prominent operating systems, including macOS, Windows, Android and iOS. Web SQL is included with Google Chrome even though Chromium 97, which was released in October 2021, deprecated and removed it for third-party contexts.

Google’s hesitancy to drop Web SQL is clarified in this document by developer advocate Thomas Steiner, who explains that replacements for Web SQL, such as IndexedDB, “show their strengths when it comes to key/value stores and structured data, but acknowledgedly also have weaknesses like the lack of a strong query language. People want SQL on the web for a reason.”