This is a proof-of-concept showing SQLDelight running with the SQLite project's WebAssembly build.
This project uses the Origin-Private FileSystem storage method to persist the database.
https://dellisd.github.io/sqldelight-sqlite-wasm
This repository is set up to build as-is right away, however it does a couple of special things.
- This project currently uses SNAPSHOT builds of SQLDelight.
- SQLite's WebAssembly builds are not distributed through NPM, so a couple of custom tasks are set up in
build.gradle.kts
to download and extract the required static resources.
Copy the sqlite.worker.js
file.
In code, load the SQLDelight worker driver with this worker script.
val worker = Worker(js("""new URL("sqlite.worker.js", import.meta.url)""").unsafeCast<String>())
val driver: SqlDriver = WebWorkerDriver(worker)
// Use your driver!
Database.Schema.awaitCreate(driver)
Make sure that you've also followed the build requirements section to ensure that the static sqlite-wasm files are also in your project's resources.