@datadome/react-native-datadome-fetch
v3.0.0
Published
Module for supporting DataDome in React Native applications using Fetch.
Readme
@datadome/react-native-datadome-fetch
DataDome bot protection for React Native fetch requests. createDataDomeFetch builds a drop-in replacement for fetch that adds the DataDome headers to every request, validates every response with the CoreDataDome SDK and retries the request after a solved challenge. Challenges are presented natively by the SDK, so there is nothing to add to your views.
Find the complete documentation on docs.datadome.co.
Requirements
| Requirement | Version |
| --- | --- |
| React Native | 0.85 or newer, New Architecture enabled (the default) |
| iOS | deployment target 15.1 or newer |
| Android | minSdkVersion 24 or newer |
Installation
npm install --save @datadome/react-native-datadome-fetch @datadome/react-native-core-datadome
cd ios && pod installThe core SDK is a peer dependency so that React Native autolinks its native module. See the documentation for the full setup.
Usage
import { DataDome, createDataDomeFetch } from '@datadome/react-native-datadome-fetch';
const dataDome = new DataDome({ clientKey: 'YOUR_CLIENT_KEY' });
const protectedFetch = createDataDomeFetch(dataDome);
const response = await protectedFetch('https://api.example.com/items', {
method: 'GET',
headers: { Accept: 'application/json' },
});