React Native SDK

@switchlabs/verify-ai-react-native ships a verification client, a React hook, and an optional camera scanner component that handles the full capture / upload / retry loop.

Install

Core SDK (client, hooks, types):

bash
npm install @switchlabs/verify-ai-react-native

With the built-in camera scanner:

bash
npm install @switchlabs/verify-ai-react-native expo-camera expo-image-manipulator expo-sensors

For offline queue support, also install @react-native-async-storage/async-storage.

For on-device inference, also install expo-file-system, react-native-fast-tflite, and configure the delegates you plan to use.

Peer dependencies

The scanner peer dependencies are intentionally optional — if you only need the verification client, none of the Expo camera modules are required.

Quick start

tsx
import { useVerifyAI } from "@switchlabs/verify-ai-react-native";
 
function ParkingScreen() {
  const { verify, loading, lastResult } = useVerifyAI({
    apiKey: process.env.EXPO_PUBLIC_VERIFY_AI_KEY!,
  });
 
  const onPhoto = async (base64: string) => {
    const result = await verify({
      image: base64,
      policy: "scooter_parking",
    });
    if (result?.is_compliant) {
      // end the ride
    }
  };
 
  return null;
}

Drop-in scanner

The scanner is exported from a separate subpath so the camera modules don't get pulled in for consumers that only use the client.

tsx
import { useVerifyAI } from "@switchlabs/verify-ai-react-native";
import { VerifyAIScanner } from "@switchlabs/verify-ai-react-native/scanner";
 
function ScannerScreen() {
  const { verify } = useVerifyAI({ apiKey: process.env.EXPO_PUBLIC_VERIFY_AI_KEY! });
 
  return (
    <VerifyAIScanner
      policy="scooter_parking"
      onCapture={(base64) => verify({ image: base64, policy: "scooter_parking" })}
      onResult={(result) => console.log(result.is_compliant ? "PASS" : "FAIL")}
      onClose={(result) => console.log("closed", result?.id)}
      showCloseButton
      overlay={{
        instructions: "Center the scooter in the frame",
        processingMessage: "Checking parking compliance...",
        failureMessage: "Parking issue detected",
        retryMessage: "Try again. {remaining} attempts left.",
        terminalResultDisplayMs: 3000,
        terminalActionLabel: "Continue",
      }}
    />
  );
}

Passing policy enables policy-aware default copy and guide overlays for scooter, bike, and forest parking policies. Override any strings through the overlay prop.

Offline mode

tsx
const { verify, queueSize, processQueue } = useVerifyAI({
  apiKey: process.env.EXPO_PUBLIC_VERIFY_AI_KEY!,
  offlineMode: true,
});
 
const result = await verify({ image: base64, policy: "scooter_parking" });
// If the network was down, result.status === "queued"
// The SDK retries automatically when connectivity returns.

Offline mode requires @react-native-async-storage/async-storage. The SDK queues transient failures (network errors, timeouts, 429, 5xx) and retries them in the background.

Metadata enrichment

The hook attaches device metadata automatically (model, OS version, app version, app build, scanner SDK version, GPS if granted) so every verification carries the context you need for incident review:

tsx
const result = await verify({
  image: base64,
  policy: "scooter_parking",
  metadata: { user_id: "usr_…", trip_id: "trip_…" },
});
 
// result.metadata also includes:
//   sdk_version, app_version, device_model, os_version, gps, etc.

API surface

| Export | Description | | ------------------------ | ------------------------------------------------------------ | | useVerifyAI(options) | React hook — exposes verify, loading, lastResult, queue helpers. | | VerifyAIClient | Direct client class. Use if you don't want the hook. | | VerifyAIScanner | Camera scanner UI (separate subpath). | | types | Re-exports VerificationResult, PolicyConfig, etc. |

See the package README on npm for the full API.

Versioning

The current published version is 2.4.x. The SDK follows semver — patch for fixes, minor for new features, major for breaking changes. Check your installed version against npm view @switchlabs/verify-ai-react-native version.

Get in Touch

Questions about pricing, integrations, or custom deployments? We'd love to hear from you.