8000 GitHub - margelo/nitro-sqlite: 💽 Fast SQLite library for NitroUI & React Native, built using Nitro Modules · GitHub
[go: up one dir, main page]

Skip to content

About

💽 Fast SQLite library for NitroUI & React Native, built using Nitro Modules

Topics

Resources

Contributing

Stars

589 stars

Watchers

4 watching

Forks

Latest commit

 

History

381 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nitro SQLite

Nitro SQLite is a SQLite library built with Nitro Modules. It shares its database implementation and TypeScript API across React Native and NitroUI. It provides synchronous and asynchronous queries, transactions, prepared statements, and batch operations.

Choose the package for your app's runtime:

Runtime Package Setup
React Native react-native-nitro-sqlite React Native guide
NitroUI nitro-sqlite NitroUI guide

Both runtimes support Drizzle ORM, TypeORM, MikroORM, Kysely, and vector search through optional companion packages.

Integration React Native NitroUI
Drizzle react-native-nitro-sqlite-drizzle nitro-sqlite-drizzle
TypeORM react-native-nitro-sqlite-typeorm nitro-sqlite-typeorm
MikroORM react-native-nitro-sqlite-mikro-orm nitro-sqlite-mikro-orm
Kysely react-native-nitro-sqlite-kysely nitro-sqlite-kysely
Vector search react-native-nitro-sqlite-vec nitro-sqlite-vec

Each companion uses the SQLite adapter for the same host. Install it from the alpha tag with an exact version, like the adapter. See the ORM setup guide. The TypeORM export in each SQLite adapter remains available for compatibility and is deprecated in favor of its companion package.

Read Supported platforms for platform status, runtime versions, and integration limits. The React Native documentation is also available at sqlite.margelo.com.

If you use a coding agent, give it the NitroSQLite skill. It links to focused guidance for connections, queries, transactions, concurrency, and migration. See the AI agent guide for what to check in generated code.

React Native installation

The 11.0.0 alpha installs from the alpha tag and requires React Native 0.88 or newer. iOS requires a deployment target of 16.0 or later, Swift Package Manager, and Xcode with Swift 6.4 or newer. Stable 10.x stays on the latest tag.

Save an exact version. npm otherwise saves ^11.0.0-alpha.0, and that range also matches the older 11.0.0-nitro-v1.x builds:

npm install --save-exact react-native-nitro-sqlite@alpha react-native-nitro-modules@1.0.0-alpha.nightly.138.g43e09c161101

For iOS, follow the React Native SwiftPM setup, including the steps for keeping other CocoaPods, or the Expo prebuild setup.

For macOS and visionOS, use Nitro SQLite 10.x with Nitro Modules 0.37.2. See the macOS setup for the macOS example and build options.

Rebuild the native app after installing. Expo projects need a development build; Expo Go cannot load this native module. See the React Native guide for details. NitroUI uses its own setup guide and Nitro version.

The React Native SQLite build enables R*Tree indexes by default on Apple platforms and Android. Set nitroSQLite.enableRTree to false in your app's package.json to omit it from the native build.

Expo projects can set up FTS5, App Groups, and system SQLite during prebuild or EAS Build by adding react-native-nitro-sqlite to the app config's plugins. For vector search, add react-native-nitro-sqlite-vec too. See Expo configuration. Existing manual iOS and Android configuration remains supported. Native setting changes require a rebuild.

Use the ORM and query builder guide to connect Drizzle ORM, TypeORM, MikroORM, or Kysely.

Example

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)')
db.execute('INSERT INTO notes (body) VALUES (?)', ['Hello'])

const { rows } = db.execute<{ id: number; body: string }>(
  'SELECT id, body FROM notes',
)
console.log(rows._array)

db.close()

Migrating from Quick SQLite

react-native-quick-sqlite 8.x was succeeded by react-native-nitro-sqlite 9.x. Follow the migration guide before updating an app with existing database files.

Community and contributing

Join the Margelo Community Discord. Contributions are welcome through issues and pull requests.

License

MIT.

About

💽 Fast SQLite library for NitroUI & React Native, built using Nitro Modules

Topics

Resources

Contributing

Stars

589 stars

Watchers

4 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

0