Guides

Embed in an Expo app

Step-by-step: native core, secure key, streaming UI, approvals.

  1. 1

    Build the native core

    Once per release — or let the included GitHub Actions release workflow produce Android jniLibs and the iOS xcframework automatically.

    cargo install cargo-ndk
    cargo ndk -t arm64-v8a -t armeabi-v7a -t x86_64 \
      -o bindings/expo/android/src/main/jniLibs \
      build -p lybo-ffi --profile release-mobile
  2. 2

    Add the packages

    npm i @lyboai/runtime expo-lyboai expo-secure-store expo-file-system expo-crypto
  3. 3

    Boot the runtime with a SecureStore-backed key

    const lybo = await createLyboClient({
      data_dir: FileSystem.documentDirectory + "lybo",
      secure_key_hex: await getOrCreateSecureKey(),
      runtime: {
        app_version: "1.0.0", device_id: installId,
        privacy_mode: "local_only",
        base_agent: { name: "Assistant", purpose: "Help in this app." },
        trusted_publishers: [["you", PUBLISHER_PUBKEY]],
      },
    });
  4. 4

    Stream progress into your UI

    lybo.onEvent((e) => {
      if (e.type === "agent.token") appendToken(e.token);
      if (e.type === "agent.step.started") setStatus(e.label);
      if (e.type === "tool.awaitingApproval") showApprovalSheet(e);
    });
  5. 5

    Handle the three outcomes

    completed → render output · awaiting_input → show the question · awaiting_approval → approval sheet, then resolveApproval.

A complete reference screen lives at examples/expo-notes-assistant/App.tsx — chat UI, streaming, question turns, and the approval sheet.
Android 16 KB pages: the module ships fully aligned (Rust core via .cargo/config.toml, JNI shim via the bundled CMakeLists.txt + build.gradle with ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON and useLegacyPackaging=false). Use NDK r27+, and verify with scripts/check-16kb.sh after toolchain changes.