How to migrate from v2 to v3
Requirements
- React Native 0.85+ with the New Architecture enabled (previously 0.72)
- iOS 15.1+ (previously iOS 11+)
- Android
minSdkVersion24+
- The client-side key available in your DataDome dashboard
Step 1: Update your dependencies
Remove the v2 package, @datadome/react-native-datadome:
npm uninstall @datadome/react-native-datadomeInstall the v3 package and the CoreDataDome SDK:
npm install @datadome/react-native-datadome-fetch @datadome/react-native-core-datadomeThe v3 SDK does not use react-native-webview. If your application does not use it directly, remove it:
npm uninstall react-native-webviewOn iOS, install the pods:
cd ios && pod installStep 2: Create a DataDome instance
DataDome instanceReplace the setSdkKey call with a DataDome instance. Give the client-side key to the constructor in the clientKey property.
Before:
import { DataDome } from '@datadome/react-native-datadome';
DataDome.getInstance().setSdkKey('YOUR_CLIENT_KEY');After:
import { DataDome } from '@datadome/react-native-datadome-fetch';
const dataDome = new DataDome({ clientKey: 'YOUR_CLIENT_KEY' });Step 3: Replace DataDomeFetch
DataDomeFetchReplace DataDomeFetch with the drop-in replacement that createDataDomeFetch returns. You do not need the datadome: true option anymore.
Before:
import { DataDomeFetch } from '@datadome/react-native-datadome';
const fetch = DataDomeFetch;
fetch('https://api.example.com/items', {
method: 'GET',
headers: { Accept: 'application/json' },
datadome: true,
});After:
import { createDataDomeFetch } from '@datadome/react-native-datadome-fetch';
const fetch = createDataDomeFetch(dataDome);
fetch('https://api.example.com/items', {
method: 'GET',
headers: { Accept: 'application/json' },
});Step 4: Remove DataDomeModal
DataDomeModalRemove the DataDomeModal component from your views. The SDK now shows the challenges with native code.
Before:
import { DataDomeModal } from '@datadome/react-native-datadome';
export default class MyApp extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<DataDomeModal />
<Text>Hello, world!</Text>
</View>
);
}
}After:
export default class MyApp extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<Text>Hello, world!</Text>
</View>
);
}
}Updated 7 days ago
Did this page help you?

