Skip to content
Nuvyntra Labs

Platform integration

React Native

Async JavaScript API plus Android AAR and iOS xcframework packs.

Overview

JavaScript API is async (NativeModules on device). Node tests load the C ABI with koffi.

1. Download

From NuvexaDB v1.0.6:

What you are buildingZipInner file
JS package (all hosts)NuvexaDB-React-Native-osx-arm64.zip or NuvexaDB-React-Native-linux-x64.zip@nuventra/nuvexadb tarball (nuventra-nuvexadb-1.0.6.tgz)
Android app`NuvexaDB-React-Native-Android.zip`Android AAR with jni/arm64-v8a/libnuvexa.so
iOS app`NuvexaDB-React-Native-iOS.zip` plus `NuvexaDB-Native-iOS.zip`compiled NuvexaDB.mm / link `Nuvexa.xcframework`
Node / Jest on a desktopsame JS tarball + NuvexaDB-Native-<rid>.ziplibnuvexa.dylib / .so / nuvexa.dll

The JS sources are the same in every NuvexaDB-React-Native-<rid>.zip. Download one.

2. Empty project

npx @react-native-community/cli init AcmeStore
cd AcmeStore

3. Add the downloaded package

npm install /path/to/nuventra-nuvexadb-1.0.6.tgz

Wire the native module:

  • Android — add the AAR from NuvexaDB-React-Native-Android.zip to the android app (or the binding’s android/ folder from the tarball) so libnuvexa.so is in jni/arm64-v8a/.
  • iOSpod install after adding the podspec from the tarball; embed Nuvexa.xcframework from NuvexaDB-Native-iOS.zip.

Desktop tests only:

export NUVEXA_NATIVE_LIB="/absolute/path/to/libnuvexa.dylib"

4. Create, open, close

import { NuvexaDatabase } from "@nuventra/nuvexadb";

const path = "app.nvx";
const db = await NuvexaDatabase.create(path, key);
await db.close();

if (await NuvexaDatabase.isEncrypted(path) && !key) {
  throw new Error("Encrypted .nvx — pass the key");
}
const opened = await NuvexaDatabase.open(path, key);
await opened.close();

On device, path must be a writable sandbox file (for example from react-native-fs DocumentDirectoryPath).

5. Delete the database

await db.close();
await RNFS.unlink(path);
try { await RNFS.unlink(path + "-wal"); } catch { /* no WAL */ }

6. Collections

await db.insert("users", JSON.stringify({ name: "Ada", age: 36 }));
console.log(await db.listCollections());
await db.renameCollection("users", "people");
await db.dropCollection("people");

7. Documents

const id = await db.insert("users", JSON.stringify({ name: "Ada", age: 36 }));
await db.insertMany("users", JSON.stringify([{ name: "Grace", age: 85 }]));
const ada = await db.findById("users", id);
await db.replace("users", JSON.stringify({ _id: id, name: "Ada Lovelace", age: 36 }));
await db.deleteById("users", id);
const rows = await db.execute("db.users.find({ age: { $gte: 21 } }).limit(20)");

8. Password for an encrypted file

Keep the key in Keychain / Keystore (for example react-native-keychain). Never ship 1234 in JS.

await db.changeEncryptionKey(currentKey, nextKey);

See Encryption notes.

Discussion

Comment on NuvexaDB. The thread lives on this component's GitHub repository (nuvyntralabs/NuvexaDB). Sign in with GitHub — Giscus uses Discussions, Utterances uses Issues.