expo-sqlite provides a robust interface for local SQLite database persistence within Expo and React Native applications. As of version 55.0.15, it integrates seamlessly with Expo SDK 55. New Expo SDK versions, and consequently updates to expo-sqlite, are typically released three times per year, aligning with the React Native release cadence. This package offers a modern promise-based API for core database operations, including creating tables, inserting, querying, and managing transactions. Its primary differentiator is the streamlined integration into the Expo ecosystem, abstracting away complex native module setup for React Native developers. It is a fundamental tool for building offline-first features and for efficient, structured local data storage, distinguishing itself from simpler key-value stores like `AsyncStorage` when complex queries or relationships are required.
npm install expo-sqliteVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to open a SQLite database, create a table, insert new notes, and fetch all existing notes, displaying them in a React Native component. It uses the modern promise-based API and proper error handling within transactions.
Update your import statements from `import * as SQLite from 'expo-sqlite'; const db = SQLite.openDatabase(...)` to `import { openDatabase } from 'expo-sqlite'; const db = openDatabase(...)` for callback-based, or `import { openDatabaseAsync } from 'expo-sqlite'; const db = await openDatabaseAsync(...)` for promise-based.Always use `async/await` with promise-based APIs (`openDatabaseAsync`, `runAsync`, `getAllAsync`) or ensure all logic dependent on a database operation's completion is placed within the success callback of the transaction or `executeSql` call.
If you need to backup or migrate data, implement application-level export/import functionality using other Expo modules like `expo-file-system` to read/write database content to user-accessible directories or cloud storage, or use `serializeAsync` / `deserializeDatabaseAsync` APIs.
Always use ES module import syntax: `import { openDatabase } from 'expo-sqlite';` or `import { openDatabaseAsync } from 'expo-sqlite';`. Ensure your project's Metro/Babel configuration correctly handles ESM.Verify that the table was correctly created before attempting to query or modify it. Check for typos in the table name in both your `CREATE TABLE` and subsequent `SELECT`/`INSERT`/`UPDATE` statements.
Change your import to `import { openDatabase } from 'expo-sqlite';` for the callback API or `import { openDatabaseAsync } from 'expo-sqlite';` for the promise API, and use `openDatabase(...)` or `await openDatabaseAsync(...)` directly.Ensure that all database modifications are wrapped within a single transaction. Avoid opening multiple simultaneous database connections for writes. If using promise-based APIs, ensure `await` is used correctly to prevent concurrent access.
Migrate all `require('expo-sqlite')` statements to `import { openDatabase } from 'expo-sqlite';` (or `openDatabaseAsync`). Ensure your build environment (e.g., Metro, Babel) is configured to handle ESM properly.