v3
For the latest version of the SDK, refer to the latest documentation.
Installation
Use npm to install @datadome/datadome-axios in your React Native project:
npm install @datadome/datadome-axiosDependencies
The SDK has two peer dependencies:
Install the SDK with its dependencies
npm install @datadome/datadome-axios react-native-webview axiosSetup
Import
Import the DataDome module in your project:
import { DataDome, DataDomeModal, DataDomeInterceptor } from '@datadome/datadome-axios';Configure DataDome
To identify the traffic, DataDome needs your client-side key. Get the key from the Dashboard. Then give it to the configure method:
export default class MyApp extends Component {
componentDidMount(): void {
DataDome.configure("Client_Side_Key");
}
}Optional: Add your API origin (v3.1+)
If you must start a DataDome session when your application starts, also give your API origin to configure. configure then sends a payload immediately. This payload improves the detection:
export default class MyApp extends Component {
componentDidMount(): void {
DataDome.configure("Client_Side_Key", origin); // with `origin` your API's origin in the form <protocol>://<host> (for example `https://example.com`)
}
}Add the modal for challenges
To show challenge pages, add a DataDomeModal component at the top of your views. When the SDK must show a challenge page, the modal shows it on top of the application.
export default class MyApp extends Component {
render() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<DataDomeModal/>
<Text>Hello, world!</Text>
</View>
);
}
}Configure Axios
Before using Axios, configure it with the DataDomeInterceptor.
Create the DataDomeInterceptor
DataDomeInterceptorDefault Axios instance
//initialize DataDome interceptor
const interceptor = new DataDomeInterceptor();Custom Axios instance
If you use a custom Axios instance, initialize the DataDomeInterceptor with that instance.
const axiosInstance = axios.create({
baseURL: 'https://your_domain.com/'
});
//initialize DataDome with custom axios instance
const interceptor = new DataDomeInterceptor({axiosInstance});Add the interceptors
After you create the DataDomeInterceptor, add it to the request and response interceptors of Axios:
import axios from 'axios';
//set request intercepter
axios
.interceptors
.request
.use(async function(request) {
return await interceptor.requestAdapter(request)
},
function(error) {
return Promise.reject(error);
}
);
//set response interceptor
axios
.interceptors
.response
.use(function (response) {
//sending mobile signals
interceptor.responseEventHandler(response);
return response;
},
async function(error) {
return await interceptor.responseAdapter(error)
}
);Error handling with DataDomeInterceptor
DataDomeInterceptorAfter it retries a failed request, DataDomeInterceptor propagates the error if the status code is not 401 or 403. Previous versions ignored these errors. A failed request then looked like a request without a response.
Impact:
- Your
catchblock now receives the errors with a status code other than 401 or 403. - You know about all failed requests, and you can handle them.
All requests that use DataDomeInterceptor can now reject with an error. When you call Axios, handle the errors with .catch() or try/catch:
axios
.get("https://example.com")
.then((res) => {
console.log('Response:', res);
})
.catch((error) => {
// Handle errors properly
console.error('Request failed:', error.response?.status, error.message);
});⚠️ Upgrade note: If your code expects the SDK to ignore some errors, update your error handling. This prevents unhandled promise rejections.
How to test
To test your integration, activate the protection on your endpoints.
Force a captcha display
Do not use theBLOCKUAUser-Agent in production
To test your integration, add the User-Agent header with the value BLOCKUA to your request. This value tells the protection module to block the request. The SDK receives the 403 response and shows a challenge.
Updated 1 day ago

