A lightweight Cordova/PhoneGap/Ionic plugin that provides a WebSQL-compatible API backed by native SQLite. Uses built-in Android/iOS SQLite APIs (no bundling), offers unlimited and durable storage, prepopulated database support, and works where WebSQL is unavailable (e.g., old iOS WKWebView). Over 600 automated tests. v1.0.7 is the latest stable release; maintained via minor patches. Key differentiator: simple WebSQL polyfill without the bulk of other SQLite plugins.
npm install cordova-plugin-sqlite-2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create an SQLite database, create a table, insert a row, and query it.
Use a persistent database name (e.g., 'mydb.db') to avoid data loss.
Rely on the default location; do not attempt to specify a custom path.
Consider using IndexedDB via libraries like Dexie or LocalForage.
Ensure the plugin is added (cordova plugin add cordova-plugin-sqlite-2) and access sqlitePlugin after deviceready event.
Delete app data or reinstall; on Android ensure storage permissions are granted.
Ensure transaction callback receives txn object and you call txn.executeSql inside it.