> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Add observability to your React Native application in 5 minutes

> See how your React Native iOS app is performing. Integrate LaunchDarkly’s new Observability SDK.

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

<p class="publishedDate">
  <em>Published September 25, 2025</em>
</p>

<img src="https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/ee16585472bee25f23f4782816ccbbd25044b846b5a0b2596cf1bfaac2f47664/assets/images/authors/alexis-roberson.png" alt="portrait of Alexis Roberson." class="authorAvatar" />

<p class="authorName">
  by Alexis Roberson
</p>

## Overview

In modern application development, feature flags are the guardrails that keep experiments controlled and rollbacks safe when conditions shift. If feature flags act as the guardrails, observability provides the visibility: the headlights (traces), mirrors (logs), and dashboard instruments (metrics) that reveal what’s happening in the environment and how well a feature is performing. Together, feature flags and observability unlock powerful insights by correlating code changes with real-time system behavior. This combination reduces time-to-diagnosis and builds greater confidence when rolling out new features.

In this post, we’ll walk through just how to add observability to a React Native application using LaunchDarkly’s observability SDK. To demonstrate the process, we’ll build on the PlusOne app, a simple counter app that includes increment (+1), reset, and error-triggering buttons. This lightweight demo provides a clean foundation to showcase how logs, traces, and errors can seamlessly flow into LaunchDarkly for monitoring and debugging.

<Frame caption="Screenshot final result of PlusOne app.">
  ![Screenshot final result of PlusOne app.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/c7807d5d592a7c3527f5eae0f8fe70f9ad87eb25c26b3c500a6992a3ad8efd84/assets/images/tutorials/ollsdk-react-native/plusone.png)
</Frame>

## Prerequisites

* LaunchDarkly account. [Sign up for a free one here](https://app.launchdarkly.com/signup).
* Visual Studio or another code editor of choice.

All code from this tutorial can be found [on GitHub](https://github.com/arober39/PlusOne).

## Setting up your environment

Before running a React Native app, make sure your development environment is set up correctly. [You can find the full setup instructions for both Android and iOS here](https://reactnative.dev/docs/set-up-your-environment?platform=android#cocoapods).

In this tutorial, we'll be running iOS, but keep in mind Expo Orbit, the platform we'll be using to run our iOS simulator, requires both Xcode and Android Studio to be installed.

After going through the instructions you should have the following installed:

* Node JS (preferably via [nvm](https://www.freecodecamp.org/news/node-version-manager-nvm-install-guide/))
* Watchman for file monitoring
* JDK via zulu package manager.
* [Android Studio](https://developer.android.com/studio/index.html). Don’t forget to set your Android\_Home environment variables.
* \[Xcode]\([https://apps.apple.com/us/app/xcode/id497799835?mt=](https://apps.apple.com/us/app/xcode/id497799835?mt=)

12. for the iOS simulator.

* [Cocoapods](https://cocoapods.org/) for iOS dependency management.
* [Expo orbit](https://expo.dev/orbit) for running expo apps Android or iOS.

If you're using Android, don't forget to add your environment variables to bash or zsh profile.

```bash title="Android vars" for="android" theme={null}
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
```

## Starting up the Plus

One app

To get started, let’s clone the [repo](https://github.com/arober39/PlusOne#) for the PlusOne app and run `npm install` to ensure the proper dependencies are present in our node\_modules file.

```bash title="Cloning repo" for="git" theme={null}
git clone https://github.com/arober39/PlusOne
```

```bash title="Install using npm" for="npm" theme={null}
cd PlusOne
npm install
```

We’ll also need to run both the prebuild command to generate the ios file and the expo run command to run the iOS simulator.

```bash title="Prebuild for iOS" for="npx" theme={null}
npx expo prebuild
```

```bash title="Run expo app" for="npm" theme={null}
npm expo run:ios
```

Now we can view the iOS app in the iPhone simulator using npm.

```bash title="Install using npm" for="npm" theme={null}
# iOS
npm run ios

# Android
npm run android
```

The app should look something like this:

<Frame caption="Screenshot final result of PlusOne app.">
  ![Screenshot final result of PlusOne app](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/c7807d5d592a7c3527f5eae0f8fe70f9ad87eb25c26b3c500a6992a3ad8efd84/assets/images/tutorials/ollsdk-react-native/plusone.png)
</Frame>

Feel free to interact with the app to ensure all is working as expected.

As you can see in the code, we have three buttons: one that adds one to the displayed number, one to bring the count back to zero and an intentional Error button to test error monitoring within the LaunchDarkly UI.

```javascript theme={null}
// app/index.tsx

import { useState } from "react";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";

export default function Index() {
 const [count, setCount] = useState(0);

 const handleReset = () => setCount(0);
 const handleIncrement = () => setCount((prev) => prev + 1);

 const triggerRecordedError = () => {
   try {
     throw new Error("Simulated controlled error from Plus One app")
   } catch (e) {
     alert("You intentionally threw an error")
   }
 };

 return (
   <View style={styles.container}>
     <View style={styles.header}>
       <Text style={styles.headerText}>Plus One</Text>
     </View>
     <View style={styles.counterWrapper}>
       <Text style={styles.counterText}>{count}</Text>
     </View>
     <View style={styles.actionsRow}>
       <ButtonBox label="Reset" onPress={handleReset} />
       <ButtonBox label="+1" onPress={handleIncrement} />
       <ButtonBox label="Error" onPress={triggerRecordedError} />
     </View>
   </View>
 );
}

type ButtonBoxProps = {
 label: string;
 onPress: () => void;
};

function ButtonBox({ label, onPress }: ButtonBoxProps) {
 return (
   <TouchableOpacity onPress={onPress} style={styles.button} activeOpacity={0.8}>
     <Text style={styles.buttonText}>{label}</Text>
   </TouchableOpacity>
 );
}


/* The rest of the application code */ 

```

Now that we have verified a working app, we can add observability support by downloading the observability React Native [SDK](https://launchdarkly.com/docs/sdk/observability/react-native).

```bash title="Install using npm" for="npm" theme={null}
npm install @launchdarkly/react-native-client-sdk
npm install @launchdarkly/observability-react-native
```

Next, you’ll need to initialize the React Native LD client in the \_layout file. Replace the in the layout file by pasting the following code.

```javascript theme={null}
// app/_layout.tsx

import { Observability } from '@launchdarkly/observability-react-native';
import { AutoEnvAttributes, LDOptions, LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';
import { Stack } from 'expo-router';
import { useEffect, useState } from 'react';

const options: LDOptions = {
 applicationInfo: {
   id: 'Plus-One',
   name: 'Sample Application',
   version: '1.0.0',
   versionName: 'v1',
 },
 debug: true,
 plugins: [
   new Observability({
     serviceName: 'my-react-native-app',
     serviceVersion: '1.0.0',
   })
 ],
};

const userContext = { kind: 'user', key: 'test-hello' };

export default function RootLayout() {
 const [client, setClient] = useState<ReactNativeLDClient | null>(null);
  useEffect(() => {
   // Initialize client
   const featureClient = new ReactNativeLDClient(
     'mob-abc123',
     AutoEnvAttributes.Enabled,
     options,
   );

   featureClient.identify(userContext).catch((e: any) => console.log(e));
  
   setClient(featureClient);
  
   // Cleanup function that runs when component unmounts
   return () => {
     featureClient.close();
   };
 }, []);

 if (!client) {
   return null;
 }
 return (
   <LDProvider client={client}>
     <Stack />
   </LDProvider>
 );
}
```

First, we’re importing the Observability SDK as well as a few LD libraries to add options and attributes to the LD client.

* Initialized the SDK and [plugin options](https://launchdarkly.github.io/observability-sdk/sdk/@launchdarkly/observability-react-native/interfaces/ReactNativeOptions.html).

- Defined the user [context](https://launchdarkly.com/docs/home/flags/contexts).
- Lastly, you initialized the client.

Now that you have defined your LD React Native client, you can implement different observability methods within your application logic.

We can do this by importing the LDObserve library in the app/\_layout.tsx file.

```javascript theme={null}
import { LDObserve } from '@launchdarkly/observability-react-native';
```

Then, add the recordError() method within the triggerRecordedError function inside the app/\_layout.tsx file. This will allow for error messages to be sent back to the LD UI.

```javascript theme={null}
 const triggerRecordedError = () => {
   try {
     throw new Error("Simulated controlled error from Plus One app")
   } catch (e) {
     LDObserve.recordError(e as Error, {feature: "test-button"})
     alert("You intentionally threw an error")
   }
 };

```

Before being able to receive data in the LD UI, you’ll need to add your mobile key to the React Native LD client, which can be found by logging in to the LD UI.

<Frame caption="Screenshot of Sign in page.">
  ![Screenshot of LD sign in page](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/c7cea96e3e1eca6fedd429951483e3c01edabe718a4417975056fce3168fd08e/assets/images/tutorials/ollsdk-react-native/LD_signin.png)
</Frame>

Once logged in, tap the settings button at the bottom left.

<Frame caption="Screenshot of landing page after sign in.">
  ![Screenshot of LD onboarding page](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/1fd113c91ef6a5dee5728ba7952397eea3c4e36da76374565a9f3cacc6bebeff/assets/images/tutorials/ollsdk-react-native/LD_onboardingpage.png)
</Frame>

Navigate to the Projects page and click create to create a new project.

<Frame caption="Screenshot of Project page.">
  ![Screenshot of project landing page](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/c6ee82f1a9f4404a83b1fe352803f314047c8bb974cd38958be7083cbacfdfda/assets/images/tutorials/ollsdk-react-native/LD_projectpage.png)
</Frame>

Define the new Project and click Create Project.

<Frame caption="Screenshot of New project widget page.">
  ![Screenshot of New project page](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/227a30a8f1a5e34f66835cd268b63284b19ac15502566bdb1f59f0b499b479fc/assets/images/tutorials/ollsdk-react-native/createnewproject.png)
</Frame>

Then, define the environment where you would like your data to be sent.

<Frame caption="Screenshot of page to create new environment.">
  ![Screenshot of create new environment widget page](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/ca8e4333fa5036845d8da3c345a0f5b8f4ba24886df8aa107955305275c51087/assets/images/tutorials/ollsdk-react-native/createnewenvironement.png)
</Frame>

Now, grab the mobile key by pressing the three dots for the environment and selecting the mobile key, which will copy the key to your keyboard.

<Frame caption="Screenshot of steps to copy mobile key">
  ![Screenshot of where to find mobile key](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/784f69d853f83d598b8769809aa1578b60133bc52369b4556ecfe04175a8737e/assets/images/tutorials/ollsdk-react-native/grabmobkey.png)
</Frame>

Then, add it to the app/\_layout file.

```javascript theme={null}
   const featureClient = new ReactNativeLDClient(
     ‘mob-abc123’,
     AutoEnvAttributes.Enabled,
     options,
   );
```

Finally, you can generate data by interacting with your app in the iOS app simulator.

Feel free to restart the app to ensure data is displaying in real time.

```bash theme={null}
npm expo run:ios
```

Once you navigate back to the LD UI, you should be able to see the logs, traces, and errors under the Monitor section.

### Logs

<Frame caption="Screenshot of final logs page.">
  ![Screenshot of logs page](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/902188cb22bd50d3b2e78c4b20b8abb34b528ac1c980cdfbfee73319ac3ee4ce/assets/images/tutorials/ollsdk-react-native/logspage.png)
</Frame>

### Traces

<Frame caption="Screenshot of final traces page.">
  ![Screenshot of traces page](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/fd1d8f260e899311e1b64578a32af092d68ee0218814266e0fc04937e51919bf/assets/images/tutorials/ollsdk-react-native/tracespage.png)
</Frame>

### Errors

<Frame caption="Screenshot of final errors page.">
  ![Screenshot of errors page](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/8c9ff74a75b2907b02e1b14b5c5054a5590c821c7b19640757f95b3862739f95/assets/images/tutorials/ollsdk-react-native/errorspage.png)
</Frame>

## Conclusion

In just a few minutes, we’ve taken the PlusOne React Native app from a simple counter to a fully observable application connected to LaunchDarkly. By setting up the SDK, initializing observability plugins, and recording errors, we now have a live feedback loop where application behavior is visible in the LaunchDarkly UI. This makes it far easier to diagnose issues, validate feature flag rollouts, and ensure smooth user experiences.

## Next Steps

Looking ahead, there are many ways to expand on what we’ve built by including features like recording [custom metrics](https://launchdarkly.com/docs/sdk/features/observability-metrics) and [session replay](https://launchdarkly.com/docs/sdk/features/session-replay-config), which provide even deeper insights into app behavior. By integrating observability at the foundation of your React Native projects, you equip your team with the clarity needed to debug faster, ship features more confidently, and deliver reliable experiences to your users.

You can also read [this article](https://launchdarkly.com/blog/welcome-highlight-to-launchdarkly/) to learn more about observability and guarded releases.
