# Expo Router | Sentry for React Native

Sentry's React Native SDK package ships with instrumentation for Expo Router. This allows you to see the performance of your navigation transitions and the errors that occur during them. This page will guide you through setting up the instrumentation and configuring it to your needs.

## [Initialization](https://docs.sentry.io/platforms/react-native/tracing/instrumentation/expo-router.md#initialization)

The code snippet below shows how to initialize the instrumentation.

`app/_layout.tsx`

```javascript
import React from "react";
import { Slot, useNavigationContainerRef } from "expo-router";
import { isRunningInExpoGo } from "expo";
import * as Sentry from "@sentry/react-native";


const navigationIntegration = Sentry.reactNavigationIntegration({
  enableTimeToInitialDisplay: !isRunningInExpoGo(),
});


Sentry.init({
  dsn: "___PUBLIC_DSN___",
  // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
  // We recommend adjusting this value in production.
  // Learn more at

  // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
  tracesSampleRate: 1.0,

  integrations: [navigationIntegration],
  enableNativeFramesTracking: !isRunningInExpoGo(),
});


function RootLayout() {
  const ref = useNavigationContainerRef();
  React.useEffect(() => {
    if (ref) {
      navigationIntegration.registerNavigationContainer(ref);

    }
  }, [ref]);

  return <Slot />;
}

export default Sentry.wrap(RootLayout);
```

## [Options](https://docs.sentry.io/platforms/react-native/tracing/instrumentation/expo-router.md#options)

You can configure the instrumentation by passing an options object to the constructor:

```javascript
Sentry.reactNavigationIntegration({
  enableTimeToInitialDisplay: true, // default: false
  routeChangeTimeoutMs: 1000, // default: 1000
  ignoreEmptyBackNavigationTransactions: true, // default: true
});
```

### [routeChangeTimeoutMs](https://docs.sentry.io/platforms/react-native/tracing/instrumentation/expo-router.md#routechangetimeoutms)

This option specifies how long the instrumentation will wait for the route to mount after a change has been initiated before the transaction is discarded. The default value is `1_000`.

### [enableTimeToInitialDisplay](https://docs.sentry.io/platforms/react-native/tracing/instrumentation/expo-router.md#enabletimetoinitialdisplay)

This option will enable automatic measuring of the time to initial display for each route. To learn more see [Time to Initial Display](https://docs.sentry.io/platforms/react-native/tracing/instrumentation/time-to-display.md). The default value is `false`.

### [ignoreEmptyBackNavigationTransactions](https://docs.sentry.io/platforms/react-native/tracing/instrumentation/expo-router.md#ignoreemptybacknavigationtransactions)

This ensures that transactions that are from routes that've been seen and don't have any spans, are not being sampled. This removes a lot of clutter, making it so that most back navigation transactions are now ignored. The default value is `true`.

## [Notes](https://docs.sentry.io/platforms/react-native/tracing/instrumentation/expo-router.md#notes)

* Slow and Frozen frames, Time To Initial Display and Time To Full Display are only available in native builds, not in Expo Go.
