Registry / database / capacitor-sqlite-android

capacitor-sqlite-android

JSON →
library0.2.0jsnpmunverified

A Capacitor plugin for native Android SQLite database operations. Version 0.2.0 provides methods for loading databases, querying single objects or lists, and inserting/updating/deleting entities directly from Capacitor apps. It requires @capacitor/core ^3.0.0 and is designed for Android only. Compared to web SQLite solutions, it offers native performance and direct file system access. However, the API is still basic (no transactions, migrations, or prepared statements) and may change in future releases.

npm install capacitor-sqlite-android
INSTALL
IMPORT
SIG · CAPACITOR-SQLITE-A
C
capacitor-sqlite-android
databasejavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CapacitorSQLiteAndroid
import { CapacitorSQLiteAndroid } from 'capacitor-sqlite-android'
import CapacitorSQLiteAndroid from 'capacitor-sqlite-android'
Named export only; no default export.
SQLiteQueryOptions
import type { SQLiteQueryOptions } from 'capacitor-sqlite-android'
import { SQLiteQueryOptions } from 'capacitor-sqlite-android'
Type import is sufficient for interfaces; value imports are not needed at runtime.
echo
import { CapSQLite } from 'capacitor-sqlite-android'; const { echo } = CapSQLite;
import { echo } from 'capacitor-sqlite-android'
Methods are not directly exported; they are accessed via the plugin instance (CapSQLite).

Demonstrates loading a database and running a parameterized query using CapacitorSQLiteAndroid plugin.

import { CapSQLite } from 'capacitor-sqlite-android'; async function initDB() { const dbName = 'myApp.db'; const dbPath = ''; // default location const result = await CapSQLite.loadDatabase({ dbName, dbPath }); console.log('Database loaded:', result.data); const query = 'SELECT * FROM users WHERE id = ?'; const values = ['1']; const user = await CapSQLite.queryForObject({ query, values }); console.log('User:', user.data); } initDB().catch(console.error);
Debug
Known issues
breakingloadDatabase returns data as string | boolean inconsistently; may break type assumptions.
fix
Check return type at runtime: if (typeof result.data === 'string') { /* success with message */ } else { /* boolean true */ }
affects: >=0.0.0
gotchaMethods are not directly importable; must use CapSQLite object.
fix
Use import { CapSQLite } from 'capacitor-sqlite-android' then call CapSQLite.echo(...).
affects: >=0.0.0
gotchaInterface SQLiteEnitytOptions has a typo (missing 'i' in 'Entity'); may cause confusion.
fix
Use SQLiteEntityOptions (if fixed in future) or ignore.
affects: >=0.0.0
deprecatedPlugin is Android-only; no iOS or web support. Using on non-Android will fail.
fix
Check platform via Capacitor.getPlatform() before calling.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'loadDatabase')
Plugin not properly registered or CapSQLite not imported.
fix
Ensure `npx cap sync` was run and import { CapSQLite } from 'capacitor-sqlite-android'.
Uncaught (in promise): Error: Database not loaded
loadDatabase() not called before other DB operations.
fix
Always call loadDatabase() first and wait for its promise to resolve.
TypeScript error: Module 'capacitor-sqlite-android' has no exported member 'echo'
Attempting to import methods directly instead of using CapSQLite.
fix
Use import { CapSQLite } from 'capacitor-sqlite-android' then CapSQLite.echo().
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
@capacitor/corerequiredPeer dependency required for Capacitor plugin system
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
capacitor-sqlite-android — npm install capacitor-sqlite-android · libregistry