- Podcasts
- Capgo Live Updates
- Custom Sqlite Extensions Capacitor
About this episode
Custom SQLite extensions let Capacitor apps run heavy calculations, like precise geospatial distance, directly in native C code instead of moving data to JavaScript. The episode explains why you should first verify SQLite already offers needed features—JSON functions, FTS5, R‑tree—before writing native code, and shows how a C scalar function such as a haversine calculator can keep 10,000‑plus rows in the database and return results in milliseconds.
Listeners learn the platform‑specific steps: static linking on iOS using the sqlite3_core macro, patching the FastSQL Swift plugin with Bun to auto‑load the extension, and on Android bundling a custom SQLite engine via requery with NDK flags that align the .so file to Android 15’s 16 KB page size. The discussion also covers version‑gating JavaScript queries to avoid crashes when native binaries lag behind OTA updates.
Topics:
- Check SQLite built‑in capabilities before creating a C extension
- Static link C extensions on iOS and inject them via a Bun patch
- Compile Android native libraries with 16 KB page alignment for Android 15
- Use version checks in JavaScript to maintain compatibility with older native shells
Full article
https://capgo.app/blog/custom-sqlite-extensions-capacitor/
