Files
turso/examples/react-native
Nikita Sivukhin 8df4221bbf wip
2026-01-18 15:22:05 +04:00
..
wip
2026-01-18 15:22:05 +04:00
2026-01-18 14:00:56 +04:00
2026-01-18 14:00:56 +04:00
wip
2026-01-18 15:17:56 +04:00
2026-01-18 14:00:56 +04:00
2026-01-18 14:00:56 +04:00
2026-01-18 14:00:56 +04:00
wip
2026-01-18 15:17:56 +04:00
2026-01-18 14:00:56 +04:00
2026-01-18 14:00:56 +04:00

Turso React Native Example

A simple example app demonstrating the Turso React Native bindings.

Prerequisites

  • Node.js 18+
  • React Native development environment set up (React Native docs)
  • Android SDK with NDK 26+
  • Rust toolchain with Android targets

Setup

1. Build the Turso native libraries

First, build the Rust libraries for Android:

# From the repo root
cd bindings/react-native
./scripts/build-rust-android.sh

This creates the native libraries in bindings/react-native/libs/android/.

2. Install dependencies

cd examples/react-native
npm install

3. Run on Android

Connect your Android device with USB debugging enabled:

# Check device is connected
adb devices

# Run the app
npm run android

4. Build a release APK

cd android
./gradlew assembleRelease

# APK location:
# android/app/build/outputs/apk/release/app-release.apk

Transfer the APK to your device and install.

What the example does

The example app demonstrates:

  • Opening an in-memory database
  • Creating tables with exec()
  • Inserting data with run() and bound parameters
  • Querying single rows with get()
  • Querying multiple rows with all()
  • Using prepared statements
  • Running transactions
  • Closing the database

Troubleshooting

"Native module not found"

Make sure you've built the native libraries:

cd ../../bindings/react-native
./scripts/build-rust-android.sh

Build fails with NDK errors

Ensure you have NDK 26 installed:

sdkmanager "ndk;26.1.10909125"
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125

App crashes on startup

Check logcat for errors:

adb logcat | grep -E "(Turso|ReactNative|FATAL)"