SDK React Native - Superagent

The React Native module helps you to protect your React Native applications using Superagent.
The module handles 403 API responses, generated by DataDome server-side integration, in order to display the associated Captcha pages.


Use the package manager npm to install datadome-superagent in your react native project repository.

npm install @datadome/datadome-superagent --save


There are 4 peer dependencies for DataDome react native module:

NOTE: If you see a message from npm during the installation of DataDome module about peer dependencies, you will have to install them yourself.

For a complete install with dependencies:

npm install --save @datadome/datadome-superagent @react-native-async-storage/async-storage async-barrier react-native-webview superagent


For iOS, update pods by going into iOS folder and make pod installation.

cd ios/ && pod install

Integration and usage


First, import DataDome module in your project

import { DataDome, DataDomeInterceptor, DataDomeModal } from '@datadome/datadome-superagent';

Set SDK Key

Add the SDK Key to DataDome instance with the method setSdkKey

export default class MyApp extends Component {
  constructor(props) {

Captcha container

The SDK needs a container to show the captcha page when needed.
Add a DataDomeModal component in top of your views. Like a modal, it will be showed only when the SDK needs to show a captcha page and can be closed by a user if he wants to (for android user).

In the DataDomeModal component, you need to set the ref of this component to the DataDome module instance.

export default class MyApp extends Component {
  render() {
    return (
    <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
      <DataDomeModal onRef={ref => (DataDome.getInstance().setContainerViewRef(ref))} />
      <Text>Hello, world!</Text>

Configure Superagent

Before start using Superagent, make sure to configure it with the DataDomeInterceptor

const superagent = require('superagent');
//configure the request agent
const agent = superagent.agent()

Use Superagent

You can now use the agent the same way you used before

  .set('accept', 'application/json')
  .then((res, err) => {
    console.log("Got response", res.status)

Force a captcha display

To force the DataDome module to display a captcha, you can send a custom User-Agent header with the value BLOCKUA. This will hint the remote protection module installed on your server to block the request and consider it coming from a bot.

  .set('User-Agent', 'BLOCKUA')
  .set('accept', 'application/json')
  .then((res, err) => {
    console.log("Got response", res.status)

Do not forget to remove this header from your code before deploying to production.
Make sure, application/json is an accepted type.


DataDome can throw some errors if it needs to. Here is the list of possible errors:

  • DATADOME ERROR: Problem on parsing of DataDomeResponse (No url object)
  • DATADOME ERROR: Can't show captcha page (No container)
  • DATADOME ERROR: Can't show captcha page (One is already in progress)
  • DATADOME ERROR: Don't put cookie headers on iOS. (Cookie handled automatically by iOS)
  • DATADOME ERROR: Captcha page closed before being passed