A reactive, offline-first SQLite database for React Native, Expo, the web, Windows and Node.
A maintained fork of WatermelonDB, on the React Native New Architecture.
Documentation · Installation · Migrating from WatermelonDB · Performance · Encryption · Discord
NitromelonDB keeps your data in SQLite and loads only what a screen asks for, so apps with tens of thousands of records still launch fast. Records are observable: change one, and every component that shows it re-renders. It syncs with your own backend.
It continues WatermelonDB by Nozbe, which hasn't kept up with React Native, iOS and Android for a while. Models, queries, writers and sync work the same way, and existing databases keep working. Coming from @nozbe/watermelondb? Follow the migration guide. (The original WatermelonDB introduction now lives in LEGACY_README.md.)
With a coding agent (Claude Code, Cursor, Codex and others). From the root of your app:
npx skills add StasDoskalenko/NitromelonDB --skill nitromelondb-installThen ask your agent to add NitromelonDB to the app, or run /nitromelondb-install. It checks the requirements, installs the packages, sets up decorators and the Expo plugin for your platform, designs the schema with you, writes the models, the database and a data layer on hooks, and checks the build. Coming from @nozbe/watermelondb, use --skill nitromelondb-migrate-from-watermelondb instead. There are also skills for schema changes, sync, audits and indexes: Agent skills.
By hand:
# Expo (development build, EAS Build or EAS Update; not Expo Go)
npx expo install nitromelondb react-native-nitro-modules
# bare React Native
yarn add nitromelondb react-native-nitro-modulesExpo apps also add "nitromelondb" to plugins in app.json. Expo needs no Babel setup for decorators; bare React Native needs four Babel plugins. Then rebuild the native app. All steps, per platform: Installation.
Requirements: React Native 0.83+ on the New Architecture, iOS 15.1+, Android minSdk 24, React Native Windows 0.84+, Node.js 22+ (for Node, Electron and tooling).
For anything else, point your agent at llms.txt (an index of the docs as Markdown) or llms-full.txt (all of it in one file).
Define models for the tables in your schema:
import { Model, Query } from 'nitromelondb'
import { children, field, text } from 'nitromelondb/decorators'
class Post extends Model {
static table = 'posts'
static associations = {
comments: { type: 'has_many', foreignKey: 'post_id' },
} as const
@text('title') title!: string
@field('is_pinned') isPinned!: boolean
@children('comments') comments!: Query<Comment>
}Then use them in components. They re-render when the data changes, wherever the change came from:
import { useQuery, useRecord, useWriter } from 'nitromelondb/hooks'
function PostScreen({ post }: { post: Post }) {
useRecord(post) // re-render when the post changes
const comments = useQuery(post.comments) // ...or when its comments do
const [togglePin, { isPending }] = useWriter(post, async (p) => {
await p.update((record) => {
record.isPinned = !record.isPinned
})
})
return (
<View>
<Text>{post.title}</Text>
<Button title={post.isPinned ? 'Unpin' : 'Pin'} onPress={() => togglePin()} disabled={isPending} />
{comments.map((comment) => (
<CommentRow key={comment.id} comment={comment} />
))}
</View>
)
}Prefer higher-order components? withObservables still works. See Components and Hooks.
Platforms
- New Architecture only. Native SQLite on iOS, Android and Windows goes through Nitro Modules. The old architecture (Paper and the legacy bridge) isn't supported.
- Expo, first class. A config plugin for development builds, EAS Build and EAS Update replaces
@morrowdigital/watermelondb-expo-plugin. The example app runs on Expo SDK 58 and React Native 0.88. - Windows. React Native Windows on the New Architecture (WinAppSDK), with the same Nitro SQLite.
- The web, on real SQLite. The same
nitromelondb/adapters/sqliteimport runs wa-sqlite in a worker in the browser, and stores data in IndexedDB. No COOP/COEP headers needed. - Node.js and Electron. SQLite through
better-sqlite3, andRemoteAdapterto run it in Electron's main process. - Simpler installs. SQLite and simdjson are compiled in. Autolinking is all you need: no Podfile, Gradle or
MainApplicationchanges, and R8 keep rules ship with the library.
For developers
- Encryption, opt-in. The database file can be encrypted in SQLCipher 4's format (AES-256) on iOS, Android, Windows, Node and Electron: turn on one switch in your app's
package.json, then giveSQLiteAdaptera passphrase. Plain databases of existing users can be encrypted in place. Apps that don't turn it on ship no cryptography from NitromelonDB, so their App Store export-compliance answer stays the same. Coming in 0.33. See Encryption. - Written in TypeScript, with strict checking, so the published types match the code.
- Decorators, both kinds. On Expo, model decorators work with no Babel setup at all. Standard (TC39) decorators with
accessorfields work too, and development builds tell you when decorators compiled but don't work. See Decorators. - Hooks:
useQuery,useRecord,useObservable,useWriter,useAtomicWriteranduseDatabaseReady, next towithObservables. - Seeding and readiness:
new Database({ seed })for initial or demo data tied to schema versions, anddatabase.readyPromise/useDatabaseReadyto gate your UI on setup. - Smaller conveniences:
database.get(Post)with a model class,findAndObserveOrNull(id), and raw SQL expressions inQ.sortBy. - Observability: nested writers, stuck readers and writers, and wrong
callWriter/callReaderuse fail loudly and say where, instead of hanging. See Observability.
Performance
Measured against WatermelonDB 0.28 on the same device, with the same benchmark apps (v0.32.0-beta.0, iPhone 18 Pro simulator, Release builds, React Native 0.88; method and raw data):
| vs WatermelonDB with JSI | vs WatermelonDB without JSI | |
|---|---|---|
| Initial sync of a fresh install (80 tables, 300 pulls) | 2.0× faster | 4.7× faster |
| Many small syncs into existing data (67 pulls, 12 tables) | 1.4× faster | 2.3× faster |
| Sync of 5,000 / 20,000 records (create, update, fetch, push) | 1.2× / 1.2× faster | 1.9× / 2.1× faster |
| Sync of 50,000 records (initial and update pulls) | 1.6× faster | 2.4× faster |
| Bulk writes and deletes (100,000 records × 10) | 1.4× faster | 2.1× faster |
A single query returning ~50,000 records right after syncing them is faster too: 1.2× faster than WatermelonDB with JSI when the app sat idle before the sync, and 4.3× when the sync runs right at launch, where WatermelonDB spends most of that query in garbage collection. One thing is slower: the stress test's query phase, 10% against WatermelonDB without JSI (level with JSI).
What makes it faster:
- Query results skip Nitro's generic
AnyMapconversion on the way to JS, and the native statement cache is a bounded LRU. - Sync skips tables with nothing to pull and finds tables with local changes in one query; large batches no longer rebuild every index.
destroyAllPermanently()andmarkAllAsDeleted()no longer slow down with the number of records.- Caches trim themselves when the OS reports memory pressure, and SQLite releases its own memory too.
The NotesApp's Android CPU, memory and frame rate are also tracked on every commit: Performance.
Tested on every pull request
- The shared correctness suite (CRUD, queries, migrations, concurrent writers, batches) runs against the real native SQLite bridge on iOS and Android.
- The NotesApp runs end-to-end tests on every platform: Maestro flows on iOS and Android (cold start, create / pin / delete, kill-and-relaunch, pagination, sync), the same scenarios except sync through WinAppDriver on Windows, and Playwright on the web.
- Sync runs end to end against a reference sync server, on SQLite and LokiJS.
Full history: changelog.
- NotesApp: a notes list with migrations, pagination and sync, on Expo for iOS, Android and the web.
- NotesApp_windows: the same app on React Native Windows. It's a separate app because RNW 0.85 is on React Native 0.85.
- benchmark: NitromelonDB and WatermelonDB side by side, measuring the same operations.
- sync-server: a small sync backend in TypeScript (Hono and SQLite) to copy from.
Each folder's README has run instructions.
SQLCipher (encryption works on iOS, Android, Windows, Node and Electron, including encrypting existing databases; progress events are next), VACUUM, macOS, paginated sync, more reliable migrations and clearer critical-error handling.
NitromelonDB is open source and needs your help. If something's missing or broken, open an issue to talk it through, and see the contributing guide for setup and testing. Good first issues are a nice place to start.
Building an app with NitromelonDB? Let us know on Discord, or add your logo to LEGACY_README.md.
WatermelonDB was created by @Nozbe, and its main author is Radek Pietruszewski. Huge thanks to them and to the original contributors for designing and building it.
NitromelonDB is maintained by Stas Doskalenko.
MIT licensed. See LICENSE.
