On this page, you will learn how to perform initial setup for React Native frontends.
Before you begin, ensure your environment meets the following requirements:
Requirement
Minimum Version
React
16.8
React Native
0.60
Node.js
16.0.0
Android SDK version
21
iOS SDK
12
Gradle
7.0
Android Gradle Plugin
7.0
Java
11
Kotlin
2.0.21
Jetpack Compose
1.4 - 1.9
Experience Vitals > Overview.To enable the New RUM Experience for web frontends at the environment level:
Experience Vitals.dynatrace.config.js file and save it into your project root.Install the Dynatrace React Native plugin:
npm install @dynatrace/react-native-plugin
For iOS projects using CocoaPods, navigate to your ios directory and run pod install to install the Dynatrace dependency.
The transformer adds modifications to your code during build. The reporter notifies the plugin when you clear the metro bundler cache.
Create or extend metro.config.js in your project root with the following configuration:
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');const defaultConfig = getDefaultConfig(__dirname);/*** Metro configuration* https://facebook.github.io/metro/docs/configuration** @type {import('metro-config').MetroConfig}*/const config = {transformer: {babelTransformerPath: require.resolve('@dynatrace/react-native-plugin/lib/dynatrace-transformer',),},reporter: require('@dynatrace/react-native-plugin/lib/dynatrace-reporter'),};module.exports = mergeConfig(defaultConfig, config);
If you already have a babel transformer (babelTransformerPath) in place, use the upstreamTransformer property in dynatrace.config.js to chain transformers.
Copy the dynatrace.config.js file you generated in the Dynatrace web UI to your project root.
The configuration file contains your beaconUrl, applicationId, and instrumentation settings. Configure the components you want to monitor for lifecycle instrumentation.
By default, you'll only see application startup and touch events. Define the components you want lifecycle-instrumented in the configuration file to capture additional events.
If you need to create a default configuration file, run:
npx configDynatrace
Update your babel.config.js file if you're using:
Add the automatic JSX runtime configuration:
module.exports = function (api) {api.cache(true);return {presets: [['babel-preset-expo',{jsxRuntime: 'automatic',jsxImportSource: '@dynatrace/react-native-plugin',},],],};};
If you're using NativeWind, use 'nativewind' as the importSource for the JSX runtime in babel.config.js. The plugin internally calls the Dynatrace JSX runtime after NativeWind's runtime.
For Expo projects, ensure your project contains android and/or ios folders by running:
npx expo prebuild
Run the instrumentation command to configure both Android and iOS projects:
npx instrumentDynatrace
This command modifies your application's *.plist and build.gradle files, enabling auto-instrumentation on Android and writing the configuration for both platforms.
Build and run your application:
react-native run-android# orreact-native run-ios
When you change your configuration in dynatrace.config.js, reset the metro cache using:
react-native start --reset-cache
Metro caches all files, and configuration changes might lead to inconsistent behavior without resetting the cache.
The automated script that runs before every start, run-android, or run-ios command no longer works with React Native 0.70+ or @react-native-community/cli 9.x+. When your dynatrace.config.js changes, manually execute npx instrumentDynatrace beforehand.
After installing and configuring OneAgent, verify that data is being collected:
Open your app and perform several actions (navigate between screens, tap buttons, and make network requests).
Experience Vitals > Overview.This data can also be analyzed directly in Grail using DQL.
It may take a few minutes for data to appear in Dynatrace after the first app launch.
After completing the initial setup, consider exploring the following topics to enhance your monitoring capabilities: