Registry / database / cordova-sqlite-react

cordova-sqlite-react

JSON →
library1.1.51jsnpmunverified

A React wrapper around cordova-sqlite-storage providing a Promise-based SQLite API. Version 1.1.51 offers utilities like openDB, closeDB, setData, getData, updateData, removeData, and query. Also includes SLStore for transparent data persistence: uses SQLite on Cordova and localStorage on web. Ships TypeScript types. Under active development (updated as needed). Requires cordova-sqlite-storage ^6.0.0 as a peer dependency.

npm install cordova-sqlite-react
INSTALL
IMPORT
SIG · CORDOVA-SQLITE-REA
C
cordova-sqlite-react
databasejavascriptv1.1.51
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.

SLStore
import { SLStore } from 'cordova-sqlite-react'
import SLStore from 'cordova-sqlite-react'
Both SLStore and Sqlite are named exports, not default.
Sqlite
import { Sqlite } from 'cordova-sqlite-react'
const Sqlite = require('cordova-sqlite-react')
ESM-only; no CommonJS support.
types (for TypeScript)
import type { SqliteType, SLStoreType } from 'cordova-sqlite-react'
import { SqliteType } from 'cordova-sqlite-react'
If you only need types, use type import to avoid runtime inclusion.

Shows basic usage: openDB, insert (setData), query (getData), and closeDB with error handling.

import { Sqlite } from 'cordova-sqlite-react'; async function main() { try { await Sqlite.openDB(); await Sqlite.setData('Users', { name: 'Alice', age: 30 }, { isCreateDate: true }); const result = await Sqlite.getData('Users'); console.log('Data:', result.values); await Sqlite.closeDB(); } catch (err) { console.error('Database error:', err); } } main();
Debug
Known issues
gotchasetData adds createdAt and updateAt columns by default unless isCreateDate is false. This may conflict with existing table schemas.
fix
Set isCreateDate: false in options if you don't want those columns.
affects: >=1.0.0
gotchagetData returns JSON strings in value field; use isParse: true to auto-parse if values are stored as JSON.
fix
Pass true as second argument to getData or parse manually.
affects: >=1.0.0
breakingQuery syntax for where/whereKey uses double quotes around values, not single quotes. This may cause SQL errors if database expects single quotes.
fix
Use stringWhere with single quotes for manual WHERE clauses, or ensure your SQLite version supports double quotes (usually yes for string comparison).
affects: >=1.0.0
deprecatedremoveData with no arguments deletes all rows in the table (DELETE FROM table). This behavior may be surprising.
fix
Always provide a where clause or use stringWhere to avoid accidental mass deletion.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'cordova-sqlite-storage'
Missing peer dependency cordova-sqlite-storage.
fix
npm install cordova-sqlite-storage
TypeError: Sqlite.openDB is not a function
Incorrect import: using default import instead of named import.
fix
Use import { Sqlite } from 'cordova-sqlite-react'
Uncaught (in promise) ReferenceError: Sqlite is not defined
Forgetting to import Sqlite, or import path typo.
fix
Ensure import { Sqlite } from 'cordova-sqlite-react' is at top of file.
cordova is not defined
Code running outside a Cordova environment (e.g., browser without cordova.js).
fix
Ensure cordova.js is loaded or use SLStore (which falls back to localStorage on web).
Upgrade
Version history
1.1.51latest on npm
Audit
Dependencies
cordova-sqlite-storagerequiredPeer dependency: actual SQLite plugin for Cordova
Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
cordova-sqlite-react — npm install cordova-sqlite-react · libregistry