This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /sdk/react-native/getting-started.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Integrate Nutrient React Native on Android and iOS

This guide walks you through the steps necessary to integrate Nutrient React Native dependency into your Android or iOS application. By the end, you’ll be able to present a PDF document in the default Nutrient user interface (UI).

Requirements

Install the following required packages depending on your platform (Android or iOS):

The Nutrient React Native dependency is installed from npmjs.com by running yarn add @nutrient-sdk/react-native in your project directory or npm install @nutrient-sdk/react-native if you’re using npm.

Creating a new project

If you already have an existing React Native project that runs on both Android and iOS using the latest version of React Native, skip to the Installation step. Otherwise, create a new one by following the steps below:

  1. In the terminal, change the current working directory to where you’ll save your project. This example uses the pdf folder created in the home directory:

    Terminal window
    mkdir ~/pdf
    cd ~/pdf
  2. Create the React Native project by running the following command:

    Terminal window
    npx @react-native-community/cli init NutrientDemo

Installing the Nutrient dependency

  1. Open the terminal app and change the location of the current working directory inside your project:

    Terminal window
    cd path/to/YourProject
  2. Add the Nutrient plugin:

    Terminal window
    yarn add @nutrient-sdk/react-native
  3. Install all the dependencies for the project:

    Terminal window
    yarn install
  4. Based on whether you are installing Nutrient React Native dependency into an Android or iOS application, make your selection and follow the steps below.

4.1. Open your project’s build.gradle file:

Terminal window
open android/build.gradle

4.2. Make sure Maven Central is in your repositories. Nutrient Android SDK is published there, so no custom repository is needed:

allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}

If you previously added https://my.nutrient.io/maven/ for the Nutrient SDK, you can remove it. Keep it only if you also use an add-on that isn’t on Maven Central yet, such as OCR (io.nutrient:nutrient-ocr).

4.3. In the same file, raise Kotlin to 2.4.10. Nutrient Android SDK’s Kotlin metadata is built with Kotlin 2.4. The React Native template leaves the Kotlin Gradle plugin unversioned, so give it the version as well:

buildscript {
ext {
kotlinVersion = "2.2.0"
kotlinVersion = "2.4.10"
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}

Keep the Android Gradle Plugin 9.2.1 and Gradle 9.4.1 that React Native 0.87 and later come with. Nutrient React Native SDK needs Android Gradle Plugin 9.1 or later.

4.4. Open the app’s build.gradle file:

Terminal window
open android/app/build.gradle

4.5. Set the compile SDK’s minor version. Nutrient’s Android Archive (AAR) metadata requires the android-37.1 platform:

android {
compileSdk rootProject.ext.compileSdkVersion
compileSdkMinor 1

compileSdkVersion in your project’s ext block is 37 in React Native 0.87 and later. If you lowered it, set compileSdk 37 in the app module. The minimum SDK version is 24, which React Native 0.87 and later already use.

If your app minifies release builds, avoid Android Gradle Plugin 9.3.0–9.3.3 and 9.4.0–9.4.1. Their R8 removes a null check in react-native-screens (b/558217403(opens in a new tab)), so the app crashes at launch. Stay on 9.2.1, or pin R8 9.4.29 or later.

Displaying a PDF

  1. Add the PDF document you want to display to your application by dragging it into your project. On the dialog that’s displayed, select Finish to accept the default integration options. You can use this Quickstart Guide PDF as an example.

    drag-and-drop-document
  2. Change the location of the current working directory back to the root project folder:

    Terminal window
    cd ..
  3. Create the assets directory if you don’t have one already:

    Terminal window
    mkdir android/app/src/main/assets
  4. Copy a PDF document into your assets directory:

    Terminal window
    cp ~/Downloads/Document.pdf android/app/src/main/assets/Document.pdf
  5. Use the NutrientView React component in your project:

    import React, {Component} from 'react';
    import {Platform} from 'react-native';
    import NutrientView, { PDFConfiguration } from '@nutrient-sdk/react-native';
    import type { Nutrient as NutrientModule } from '@nutrient-sdk/react-native';
    import { NativeModules } from 'react-native';
    const Nutrient: NutrientModule = NativeModules.Nutrient;
    Nutrient.setLicenseKey(null);
    const DOCUMENT =
    Platform.OS === 'ios' ? 'Document.pdf' : 'file:///android_asset/Document.pdf';
    export default class NutrientDemo extends Component<{}> {
    render() {
    var pdfRef: React.RefObject<NutrientView | null> = React.createRef();
    return (
    <NutrientView
    document={DOCUMENT}
    configuration={{
    showThumbnailBar: PDFConfiguration.ShowThumbnailBar.SCROLLABLE,
    pageTransition: PDFConfiguration.PageTransition.SCROLL_CONTINUOUS,
    scrollDirection: PDFConfiguration.ScrollDirection.VERTICAL,
    }}
    ref={pdfRef}
    fragmentTag="PDF1"
    style={{flex: 1}}
    />
    );
    }
    }
  6. The app is now ready to launch! Go back to the terminal app and run:

    Terminal window
    npx react-native run-android
    Terminal window
    npx react-native run-ios

Expo

If you’re using Expo, refer to the blog post that explains how to use Nutrient for React Native with Expo.

Next steps

To learn more about React Native, make sure to check out the following blog posts: