Install the Mobile React Native agent

BETA

The New Relic Mobile agent for React Native can be installed using npm. The install process adds native dependencies, moves the newrelic.json configuration file into the respective native apps, and adds the required import NewRelic from 'newrelic-mobile-rn'; line to your App.js.

Get access

Check the compatibility and requirements before installing. If you are new to developing mobile applications, also review our mobile developer's tools reference.

To request beta access to New Relic Mobile's React Native agent, contact mobilebeta@newrelic.com. Our Mobile team will then send you the JSON configuration file.

Install the agent

To install New Relic's React Native agent npm package:

  1. Download and install both the agent and the New Relic CLI:

    npm install newrelic-mobile-cli
    npm install newrelic-mobile-rn
  2. Install your pods:

    cd ios
    pod install
  3. Set up the agent:

    npx newrelic-mobile-react-native setup --verbose
    
  4. In order for the agent to capture JS errors, after you have started the agent, be sure to call:

    NewRelic.setJSAppVersion("YOUR_BUNDLE_VERSION")

    Use the version value listed in your package.json file to associate JS errors with a particular JS bundle.

  5. Generate some traffic for your app, then wait a few minutes for your app to send data to New Relic.

If Gradle and Maven are part of your process, the agent will be installed automatically.

Configure the agent

As part of the installation process, New Relic provides a newrelic.json file. This contains configuration specific to your application and is enabled by default, so no additional configuration by you is needed.

If you change any of the information in the newrelic.json file, you must remove and reconfigure the agent:

npx newrelic-mobile-react-native remove --verbose
npx newrelic-mobile-react-native setup --verbose

If you need to change your application's name, follow New Relic's standard procedures to rename your mobile app.

Verify data is being reported

To verify that data is being sent and received:

  1. Add a test event, and verify that it is being received by sending an event on agent start:

    NewRelic.recordCustomEvent("TestReactNativeEvent","TestName", { "testKey":"testValue"} )
  2. Run the following NRQL query:

    SELECT * FROM TestReactNativeEvent

Troubleshooting

Occasionally you may see warnings about known issues that seem oriented to New Relic. Assuming you can move forward, this should not affect your app.

If no data appears, follow our Mobile React Native troubleshooting procedures.

View mobile app performance in New Relic

To view your app's performance in the New Relic Mobile UI:

  1. Go to rpm.newrelic.com/mobile > (select a mobile app).
  2. From the Mobile Overview page, get a high-level summary of your mobile app, then drill down into additional details; for example, analyze crashes and JavaScript errors.

For more information, see the Mobile React Native best practices guide.

For more help

During the public beta, we welcome your questions and comments through the React Native beta discussion board in New Relic's Explorers Hub. Support requests also will be routed there.