Registry / database / sqlite-mobile

sqlite-mobile

JSON →
library0.1.4jsnpmunverified

sqlite-mobile is a lightweight, TypeScript-first SQLite client optimized for mobile and edge environments. Version 0.1.4 is the current stable release, with irregular cadence. It provides a simple async API over SQLite, focusing on minimal dependencies and cross-platform compatibility (Node.js, React Native, Bun). Unlike better-sqlite3, it is designed for mobile runtimes and supports synchronous and asynchronous operations.

npm install sqlite-mobile
INSTALL
IMPORT
SIG · SQLITE-MOBILE
S
sqlite-mobile
databasejavascriptv0.1.4
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.

Database
import { Database } from 'sqlite-mobile'
const Database = require('sqlite-mobile').Database
Default export is Database constructor; ESM import recommended.
Statement
import { Statement } from 'sqlite-mobile'
import { statement } from 'sqlite-mobile'
Type export; note case sensitivity.
openDatabase
import { openDatabase } from 'sqlite-mobile'
import { open } from 'sqlite-mobile'
Function to open/create a database file asynchronously.
type Database
import type { Database } from 'sqlite-mobile'
import { Database } from 'sqlite-mobile'
Use type import for type-only usage to avoid runtime overhead.

Opens an in-memory database, creates a table, inserts a row, queries all rows, and logs the result.

import { openDatabase } from 'sqlite-mobile'; async function main() { const db = await openDatabase(':memory:'); await db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)'); const stmt = await db.prepare('INSERT INTO users VALUES (?, ?)'); await stmt.run(1, 'Alice'); const rows = await db.all('SELECT * FROM users'); console.log(rows); await db.close(); } main().catch(console.error);
Debug
Known issues
breakingIn v0.1.0, the API changed from synchronous to asynchronous by default. Existing sync code will break.
fix
Use async/await or .then() for all database operations.
affects: <0.1.0
deprecatedThe method `db.close()` is deprecated in favor of `db.dispose()`
fix
Replace `db.close()` with `db.dispose()`.
affects: >=0.1.2 <0.1.4
gotchaWhen using `prepare()` the statement object is not automatically finalized; must call `stmt.finalize()` to avoid resource leaks.
fix
Call `stmt.finalize()` after done with a statement, or use `db.prepareAndRun()` for one-offs.
affects: >=0.1.0
breakingStarting from v0.1.3, the package is ESM-only. CommonJS require() will fail.
fix
Use import syntax or switch to dynamic import().
affects: >=0.1.3
gotchaOn React Native, `better-sqlite3` is not available; must use the platform-specific native module.
fix
Ensure you have the correct native SQLite library configured for your environment.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'better-sqlite3'
Optional dependency better-sqlite3 not installed when running in Node.js.
fix
Install better-sqlite3: npm install better-sqlite3
TypeError: db.all is not a function
Calling synchronous method on async API version (pre v0.1.0 style) or forgetting await.
fix
Use await db.all(...) or ensure using async-compatible version.
SyntaxError: The requested module 'sqlite-mobile' does not provide an export named 'Database'
Using CommonJS require() with ESM-only version (>=0.1.3).
fix
Use import { Database } from 'sqlite-mobile' or add type: module to package.json.
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
better-sqlite3optionalNative SQLite binding for Node.js environments
Agent activity
13 hits · last 30 days
node
10
Meta
1
OpenAI (training)
1
Resources
sqlite-mobile — npm install sqlite-mobile · libregistry