# Capture App Start Errors | Sentry for React Native

##### Alpha Testing

Sentry React Native SDK v8 is currently in alpha testing. This feature is available for early adopters and may undergo changes before the stable release.

By default, the React Native SDK initializes the native SDK underneath the `init` method called on the JS layer. As a result, the SDK has a current limitation of not capturing native crashes that occur prior to the `init` method being called on the JS layer.

Starting with SDK version 8.0.0, you can initialize Sentry natively before JavaScript loads, enabling capture of app start errors and crashes that occur during:

* Native module initialization
* JavaScript bundle loading
* Early React Native bridge setup

This feature uses a `sentry.options.json` configuration file and native initialization APIs that read from this file.

##### SDK Version Requirement

This feature requires Sentry React Native SDK version 8.0.0 or higher.

## [Configuration File](https://docs.sentry.io/platforms/react-native/manual-setup/app-start-error-capture.md#configuration-file)

Create a `sentry.options.json` file in your React Native project root with the same options you currently have in `Sentry.init`:

`sentry.options.json`

```json
{
  "dsn": "https://key@example.io/value",
  "debug": true,
  "environment": "production",
  "tracesSampleRate": 1.0,
  "enableTracing": true
}
```

##### Options Merging

Options from `sentry.options.json` are merged with options from `Sentry.init()` in JavaScript. Options specified in JavaScript take precedence over the configuration file, allowing you to override settings at runtime.

## [Android Setup](https://docs.sentry.io/platforms/react-native/manual-setup/app-start-error-capture.md#android-setup)

Initialize Sentry in your `MainApplication` class:

`android/app/src/main/java/.../MainApplication.kt`

```kotlin
import io.sentry.react.RNSentrySDK

class MainApplication : Application(), ReactApplication {
    override fun onCreate() {
        super.onCreate()
        RNSentrySDK.init(this)
        // ... rest of your initialization code
    }
}
```

## [iOS Setup](https://docs.sentry.io/platforms/react-native/manual-setup/app-start-error-capture.md#ios-setup)

Initialize Sentry in your `AppDelegate`:

`ios/YourApp/AppDelegate.mm`

```objective-c
#import <RNSentry/RNSentry.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [RNSentrySDK start];
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end
```

## [Expo Setup](https://docs.sentry.io/platforms/react-native/manual-setup/app-start-error-capture.md#expo-setup)

If you're using Expo, you can enable native initialization automatically using the Expo plugin:

`app.json`

```json
{
  "expo": {
    "plugins": [
      [
        "@sentry/react-native/expo",
        {
          "useNativeInit": true
        }
      ]
    ]
  }
}
```

When `useNativeInit` is set to `true`, the Expo plugin automatically:

* Creates `sentry.options.json` from your Expo config
* Adds `RNSentrySDK.init()` to your Android `MainApplication`
* Adds `RNSentrySDK.start()` to your iOS `AppDelegate`
