{"id":46047,"library":"react-native-sqlite-2","title":"React Native SQLite 2","description":"React Native SQLite 2 is a native SQLite3 plugin for React Native supporting iOS, Android, Windows, and macOS. It provides a WebSQL-compatible API and serves as a drop-in replacement for react-native-sqlite-storage, specifically solving issues with null characters (\\u0000) in string data and attachment storage that affected PouchDB compatibility. It uses sqlite-android to deliver a newer SQLite version on Android with support for JSON1, CTE, expression indexes, and FTS5. Current stable version: 3.6.3. Release cadence is irregular; maintained by craftzdog. Key differentiator: PouchDB-friendly due to proper handling of null characters and stable attachment storage, and a more up-to-date SQLite engine on Android.","status":"active","version":"3.6.3","language":"javascript","source_language":"en","source_url":"https://github.com/craftzdog/react-native-sqlite-2","tags":["javascript","react-native","ios","android","pouchdb","sqlite","typescript"],"install":[{"cmd":"npm install react-native-sqlite-2","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-sqlite-2","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-sqlite-2","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import. No named exports; the module exports a single object with openDatabase and deleteDatabase.","wrong":"const SQLite = require('react-native-sqlite-2')","symbol":"SQLite","correct":"import SQLite from 'react-native-sqlite-2'"},{"note":"openDatabase takes positional arguments: name, version, description, size. Object argument is not supported.","wrong":"const db = SQLite.openDatabase({name: 'test.db', version: '1.0'})","symbol":"openDatabase","correct":"const db = SQLite.openDatabase('test.db', '1.0', '', 1)"},{"note":"deleteDatabase is a method on the default export, not a named export.","wrong":"const { deleteDatabase } = require('react-native-sqlite-2'); deleteDatabase('test.db')","symbol":"deleteDatabase","correct":"SQLite.deleteDatabase('test.db')"}],"quickstart":{"code":"import SQLite from 'react-native-sqlite-2';\n\nconst db = SQLite.openDatabase('test.db', '1.0', '', 1);\ndb.transaction((txn) => {\n  txn.executeSql(\n    'CREATE TABLE IF NOT EXISTS users (user_id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(30))',\n    []\n  );\n  txn.executeSql('INSERT INTO users (name) VALUES (?)', ['Alice']);\n  txn.executeSql('SELECT * FROM users', [], (tx, res) => {\n    for (let i = 0; i < res.rows.length; ++i) {\n      console.log('User:', res.rows.item(i).name);\n    }\n  });\n});","lang":"javascript","description":"Opens a database, creates a table, inserts a row, and queries all rows using WebSQL-compatible transaction API."},"warnings":[{"fix":"Use positional arguments: openDatabase('mydb', '1.0', '', 1)","message":"openDatabase expects positional arguments (name, version, description, size). Passing an object will fail silently or throw.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use openDatabase('mydb', '1.0', '', 1).catch(err => console.error(err))","message":"The 'success' callback in openDatabase is deprecated. Use Promises or async/await.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use absolute paths if you need custom location; otherwise rely on default.","message":"On Android, the database file is created in a default location. Using relative paths may cause unexpected behaviors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Update React Native to 0.60+ and run pod install in ios/ directory.","message":"In version 3.0.0, the package dropped support for React Native < 0.60 and switched to autolinking. Manual linking is no longer required but pod install is needed for iOS.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure your app does not rely on foreign keys being off by default.","message":"Foreign key constraints are enabled automatically on database initialization, which may affect existing schemas.","severity":"gotcha","affected_versions":">=0.8.0"}],"env_vars":null,"search_vec":"'2':4,8 '3.6.3':86 'affect':58 'android':19,65,73,120,126 'api':29 'attach':55,108 'cadenc':88 'charact':49,105 'compat':28,60 'craftzdog':93 'cte':78 'current':83 'data':53 'date':116 'deliv':67 'differenti':95 'drop':35 'drop-in':34 'due':99 'engin':118 'express':79 'friend':98 'fts5':82 'handl':102 'index':80 'io':18,125 'irregular':90 'issu':46 'javascript':121 'json1':77 'key':94 'maco':22 'maintain':91 'nativ':2,6,11,16,41,124 'newer':69 'null':48,104 'plugin':13 'pouchdb':59,97,127 'pouchdb-friend':96 'proper':101 'provid':24 'react':1,5,15,40,123 'react-nat':122 'react-native-sqlite-storag':39 'releas':87 'replac':37 'serv':31 'solv':45 'specif':44 'sqlite':3,7,42,64,70,117,128 'sqlite-android':63 'sqlite3':12 'stabl':84,107 'storag':43,56,109 'string':52 'support':17,75 'typescript':129 'u0000':50 'up-to-d':113 'use':62 'version':71,85 'websql':27 'websql-compat':26 'window':20","created_at":"2026-06-07T12:58:01.855435+00:00","updated_at":"2026-06-07T12:58:01.855435+00:00","problems":[{"fix":"Run npm install react-native-sqlite-2 --save and for RN < 0.60 run react-native link react-native-sqlite-2","cause":"Package not installed or not linked correctly (pre-autolinking).","error":"Error: Cannot find module 'react-native-sqlite-2'"},{"fix":"Use default import: import SQLite from 'react-native-sqlite-2'","cause":"Incorrect import; default import used incorrectly.","error":"TypeError: SQLite.openDatabase is not a function"},{"fix":"Manage database lifecycle properly; use a single instance and avoid closing while transactions are pending.","cause":"Attempting to execute SQL on a database after it has been closed or after a transaction has ended.","error":"The database has been closed"},{"fix":"Use ? placeholders only for values, not for table/column names.","cause":"Using parameter placeholders incorrectly (e.g., using ? for identifiers or wrong syntax).","error":"SQLite3: Error while executing SQL: near \"?\": syntax error"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/craftzdog/react-native-sqlite-2#readme","github":"https://github.com/craftzdog/react-native-sqlite-2","docs":null,"changelog":null,"pypi":null,"npm":"react-native-sqlite-2","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}