Registry / database / react-native-sqlite-storage

react-native-sqlite-storage

JSON →
library6.0.1jsnpmunverified

react-native-sqlite-storage provides native SQLite3 bindings for React Native on Android and iOS. Version 6.0.1 supports both callback and Promise-based APIs, transactions, pre-populated database import, and Windows via callback. It requires react-native >=0.14.0 and has been tested with React 16.2. The library is the standard choice for SQLite in React Native, offering a familiar Cordova-like API. It supports automatic linking via CocoaPods for RN >=0.60 and manual linking for older versions.

npm install react-native-sqlite-storage
INSTALL
IMPORT
SIG · REACT-NATIVE-SQLIT
R
react-native-sqlite-storage
databasejavascriptv6.0.1
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.

SQLite
✓ import { SQLite } from 'react-native-sqlite-storage'
✗ const SQLite = require('react-native-sqlite-storage'); // may need .default
Default export is an object containing SQLite, openDatabase, etc. Use named import for clarity.
openDatabase
✓ import { openDatabase } from 'react-native-sqlite-storage'
Also available as SQLite.openDatabase if using default import.
enablePromise
✓ import { enablePromise } from 'react-native-sqlite-storage'; enablePromise(true);
✗ import { SQLite } from 'react-native-sqlite-storage'; SQLite.enablePromise(true); // works but less explicit
Call once at startup to enable Promise-based API instead of callbacks.

Open a SQLite database, create table, insert and select data using callbacks.

import { openDatabase } from 'react-native-sqlite-storage'; const db = openDatabase({ name: 'test.db', location: 'default' }); db.transaction(tx => { tx.executeSql('CREATE TABLE IF NOT EXISTS Users (id INTEGER PRIMARY KEY, name TEXT)', []); tx.executeSql('INSERT INTO Users (name) VALUES (?)', ['Alice']); tx.executeSql('SELECT * FROM Users', [], (_, results) => { for (let i = 0; i < results.rows.length; i++) { console.log(results.rows.item(i).name); } }); });
Debug
Known issues
breakingEnable promise mode explicitly with SQLite.enablePromise(true) before using Promise-based API.
fix
Call enablePromise(true) once at app startup.
affects: >=3.0.0
breakingReact Native 0.60+ requires CocoaPods for iOS; manual linking will fail.
fix
Run 'cd ios && pod install' after npm install.
affects: >=0.60
gotchaDatabase location must be specified; 'default' is recommended for most cases.
fix
Use { name: 'mydb', location: 'default' }.
affects: >=1.0.0
deprecatedUsing require() style import may lead to missing default export issues.
fix
Use ES6 named imports.
affects: >=5.0.0
gotchaTransaction callbacks must be synchronous; do not use async/await inside tx callback.
fix
Use promise-based transactions with execSQL for async operations.
affects: >=1.0.0
Errors
Common errors & fixes
Module react-native-sqlite-storage cannot be found
Package not installed or not linked.
fix
Run 'npm install react-native-sqlite-storage' and for RN <0.60: 'react-native link react-native-sqlite-storage'.
No such module 'libsqlite3'
Missing SQLite library linking in Xcode (iOS).
fix
Add 'sqlite3.0.tbd' to 'Link Binary With Libraries' in Xcode.
TypeError: Cannot read property 'enablePromise' of undefined
Default import not destructured.
fix
Use 'import { SQLite } from 'react-native-sqlite-storage'' instead of default import.
database is not open
Attempting to use database after closing or before opening.
fix
Check that db is opened before performing operations; handle using promises/callbacks.
Upgrade
Version history
6.0.1latest on npm
Audit
Dependencies
react-nativerequiredpeer dependency required for React Native platform APIs
Agent activity
10 hits · last 30 days
node
8
Resources
react-native-sqlite-storage — npm install react-native-sqlite-storage · libregistry