Skip to content
Back to Docs

Mobile SDK

React Native

Native bridge for device fingerprinting, bot detection, and threat intelligence on iOS and Android.

terminal
npm install @lightningresearch/react-native

Native SDK dependencies

The React Native package bridges to the LRDefender native SDKs. Add the platform artifacts before rebuilding.

android/app/build.gradle.kts
// android/app/build.gradle.kts
dependencies {
    implementation("com.lightningresearch:sdk:2.0.0")
}
terminal
# Add the LRDefender Swift package in Xcode, then:
cd ios && pod install

Autolinking is supported on React Native 0.60+. Rebuild after install: npx react-native run-ios / run-android.

LRDefender.configure()

Call once at app startup before using hooks. The second argument is region: us, eu, or auto.

App.tsx
import { useEffect } from 'react';
import LRDefender, { useDeviceId, useBot, useThreat } from '@lightningresearch/react-native';

export default function App() {
  useEffect(() => {
    LRDefender.configure('lr_your_api_key', 'auto').catch(console.error);
  }, []);

  const { data: identity, isLoading, error } = useDeviceId({ tag: 'app_launch' });
  const { data: bot } = useBot();
  const { data: threat } = useThreat();

  if (isLoading) return <ActivityIndicator />;
  if (error) return <Text>Error: {error.message}</Text>;

  return (
    <View>
      <Text>Device: {identity?.deviceId}</Text>
      <Text>Bot: {bot?.isBot ? 'yes' : 'no'}</Text>
      <Text>VPN: {threat?.isVpn ? 'yes' : 'no'}</Text>
    </View>
  );
}

Hooks

Hook
Returns
useDeviceId(opts?)
{ data: DeviceIdentity, isLoading, error, refetch }
useBot(opts?)
{ data: BotResult, isLoading, error, refetch }
useThreat(opts?)
{ data: ThreatResult, isLoading, error, refetch }
deferred-fetch.tsx
// Defer initial fetch until you call refetch()
const { data, refetch } = useDeviceId({ immediate: false, tag: 'checkout' });

async function onLogin() {
  await refetch();
}

Expo managed workflow

Expo Go does not include the LRDefender native module. Use a development build or a config plugin to bundle the native SDKs. Once linked, the JS hooks work identically.