Registry / database / expo-sqlite-legacy-adapter

expo-sqlite-legacy-adapter

JSON →
library0.2.0jsnpmunverified

Adapter that wraps the newer expo-sqlite (SDK 51+) to behave like the legacy WebSQL-compatible API removed in Expo SDK 52. Version 0.2.0 is the latest and only stable release. This package enables legacy libraries (e.g., IndexedDBShim) that depend on WebSQL to continue functioning on modern Expo SDKs. Unlike the original expo-sqlite/legacy which was deprecated, this adapter is a community-maintained shim with 100% feature coverage for common WebSQL patterns as demonstrated by test results. It requires expo-sqlite as a peer dependency and is compatible with Expo SDK 51 and above.

npm install expo-sqlite-legacy-adapter
INSTALL
IMPORT
SIG · EXPO-SQLITE-LEGACY
E
expo-sqlite-legacy-adapter
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.

createWebSQLWrapper
import { createWebSQLWrapper } from 'expo-sqlite-legacy-adapter';
const createWebSQLWrapper = require('expo-sqlite-legacy-adapter').createWebSQLWrapper;
Default export not provided; must use named import.
openDatabase
const { openDatabase } = createWebSQLWrapper(ExpoSQLite);
import { openDatabase } from 'expo-sqlite-legacy-adapter';
openDatabase is not directly exported; it is obtained by calling createWebSQLWrapper with expo-sqlite.
runComparisonTests
import { runComparisonTests } from 'expo-sqlite-legacy-adapter/tests';
import { runComparisonTests } from 'expo-sqlite-legacy-adapter';
Tests are exported from a separate subpath 'expo-sqlite-legacy-adapter/tests'.

Shows how to create a WebSQL-compatible database wrapper and run a transaction with SQL statements.

import { createWebSQLWrapper } from 'expo-sqlite-legacy-adapter'; import * as ExpoSQLite from 'expo-sqlite'; const WebSQLWrapper = createWebSQLWrapper(ExpoSQLite); const openDatabase = WebSQLWrapper.openDatabase; const db = openDatabase('my-database.db'); db.transaction(tx => { tx.executeSql( 'CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY NOT NULL, name TEXT);' ); tx.executeSql( 'INSERT INTO items (name) VALUES (?);', ['test'], (_, result) => { console.log('Insert ID:', result.insertId); } ); }, error => console.error('Transaction error:', error), () => console.log('Transaction completed') );
Debug
Known issues
gotchaThe adapter only works with Expo SDK 51 and above; lower SDKs are not supported.
fix
Upgrade to Expo SDK 51+ or use the original expo-sqlite/legacy (deprecated).
affects: <0.2.0
deprecatedExpo's native expo-sqlite/legacy was removed in SDK 52; this adapter replaces it but may have subtle behavioral differences.
fix
Refer to test output for known divergences (e.g., Test#4 about write in readTransaction).
affects: >=0.2.0
gotchaThe adapter does not export openDatabase directly; it must be obtained via createWebSQLWrapper.
fix
Use `const { openDatabase } = createWebSQLWrapper(ExpoSQLite);`.
affects: >=0.2.0
gotchaError codes from SQLite may not match the original legacy adapter exactly (YMMV).
fix
Do not rely on specific error codes; check error messages instead.
affects: >=0.2.0
Errors
Common errors & fixes
TypeError: (0 , _expoSqliteLegacyAdapter.createWebSQLWrapper) is not a function
Importing the package incorrectly, possibly using default import instead of named import.
fix
Use named import: `import { createWebSQLWrapper } from 'expo-sqlite-legacy-adapter';`
Cannot find module 'expo-sqlite'
Missing peer dependency expo-sqlite.
fix
Run `npm install expo-sqlite` (or `expo install expo-sqlite`).
openDatabase is not defined
Trying to use openDatabase as a direct export instead of obtaining it from createWebSQLWrapper.
fix
Call createWebSQLWrapper first: `const { openDatabase } = createWebSQLWrapper(ExpoSQLite);`
Module not found: Can't resolve 'expo-sqlite-legacy-adapter/tests'
Importing test module without proper project configuration (e.g., missing React Native or Metro bundler).
fix
Ensure your project is set up with React Native and Metro can resolve the path.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
expo-sqliterequiredPeer dependency; the adapter wraps expo-sqlite's native module to provide WebSQL-compatible API.
Agent activity
9 hits · last 30 days
node
8
Resources
expo-sqlite-legacy-adapter — npm install expo-sqlite-legacy-adapter · libregistry