Getting Started
Install Nitro SQLite, rebuild your React Native app, and run your first query.
Nitro SQLite gives React Native apps a local SQLite database on iOS, macOS, visionOS, and Android. Start by installing its native package and Nitro Modules, then open a database with open().
1. Install the packages
Nitro SQLite requires React Native 0.75 or newer, React 17 or newer, and react-native-nitro-modules 0.37.1 or newer.
npm install react-native-nitro-sqlite react-native-nitro-modules2. Set up the native project
The default database location needs no custom SQLite settings. If your project has an ios directory, install the native pods after adding the packages:
npx pod-installAndroid needs no additional Nitro SQLite configuration for the default setup. For a React Native macOS project, install CocoaPods from its macos directory. Use Configuration for the shared package.json options. The iOS, Android, and macOS pages cover platform settings and build alternatives.
3. Rebuild the app
An already installed binary cannot load a native module added only to JavaScript. From a standard React Native CLI project, run the native build for your platform:
npm run ios
# or
npm run androidIf your app uses different scripts, run its equivalent native build. See the React Native build setup for platform prerequisites.
For an Expo project, build a native app for your platform:
npx expo run:ios
# or
npx expo run:androidNote
Expo Go does not include Nitro SQLite. Use a native build after adding the package.
Expo's run commands generate native directories when they do not exist. If your project keeps generated native directories, follow Expo's prebuild guidance to refresh them after adding a native dependency, then rebuild.
4. Run your first query
open() returns a connection bound to a database name. SQLite creates the file if it does not exist. This example creates a table, binds a value to ?, and reads it back:
import { open } from 'react-native-nitro-sqlite'
const db = open({ name: 'app.sqlite' })
db.execute(`
CREATE TABLE IF NOT EXISTS notes (
id INTEGER PRIMARY KEY,
body TEXT NOT NULL
)
`)
const body = 'Read the docs'
db.execute('INSERT INTO notes (body) VALUES (?)', [body])
const { rows } = db.execute<{ id: number; body: string }>(
'SELECT id, body FROM notes WHERE body = ?',
[body],
)
console.log(rows._array)
db.close()Bind user supplied values as parameters rather than putting them into the SQL string. The row generic gives rows._array and rows.item(index) a TypeScript shape; it does not validate database values at runtime. For more result details, see parameters and results.
Keep going
Start with databases and connections for SQLite fundamentals. The Concepts section covers data, queries, transactions, and isolation.
For Nitro SQLite APIs, see database lifecycle, sync and async, and parameters and results. The generated API reference lists public exports and method signatures.