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-nativein your project directory ornpm install @nutrient-sdk/react-nativeif you’re using npm.
- A development environment(opens in a new tab) for running React Native projects using the React Native CLI (not the Expo CLI)
- React Native 0.87 or later
- The latest stable version of Android Studio(opens in a new tab)
- The Android NDK(opens in a new tab)
- An Android Virtual Device(opens in a new tab) or a hardware device
- The latest stable version of Xcode(opens in a new tab)
- The latest stable version of CocoaPods(opens in a new tab). If you don’t already have CocoaPods installed, follow the CocoaPods installation(opens in a new tab) guide to install CocoaPods on your Mac. You can check your version of CocoaPods with
pod --version.
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:
In the terminal, change the current working directory to where you’ll save your project. This example uses the
pdffolder created in the home directory:Terminal window mkdir ~/pdfcd ~/pdfTerminal window cd /d %userprofile%mkdir pdfcd pdfCreate the React Native project by running the following command:
Terminal window npx @react-native-community/cli init NutrientDemo
Installing the Nutrient dependency
Open the terminal app and change the location of the current working directory inside your project:
Terminal window cd path/to/YourProjectAdd the Nutrient plugin:
Terminal window yarn add @nutrient-sdk/react-nativeInstall all the dependencies for the project:
Terminal window yarn installBased 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:
open android/build.gradle4.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:
open android/app/build.gradle4.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 1compileSdkVersion 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.
4.1. Open your project’s Podfile in a text editor:
open ios/PodfileUpdate the minimum iOS platform version to iOS 17:
... platform :ios, min_ios_version_supported platform :ios, '17.0'...4.2. Change the location of the current working directory to the ios folder:
cd ios4.3. Install the CocoaPods dependencies:
pod install4.4. Open your project’s Workspace in Xcode:
open YourProject.xcworkspace4.5. Make sure the deployment target is set to 17.0 or higher:

4.6. Change View controller-based status bar appearance to YES in your project’s Info.plist:
Displaying a PDF
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.

Change the location of the current working directory back to the root project folder:
Terminal window cd ..Create the
assetsdirectory if you don’t have one already:Terminal window mkdir android/app/src/main/assetsCopy a PDF document into your
assetsdirectory:Terminal window cp ~/Downloads/Document.pdf android/app/src/main/assets/Document.pdfUse the
NutrientViewReact 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 (<NutrientViewdocument={DOCUMENT}configuration={{showThumbnailBar: PDFConfiguration.ShowThumbnailBar.SCROLLABLE,pageTransition: PDFConfiguration.PageTransition.SCROLL_CONTINUOUS,scrollDirection: PDFConfiguration.ScrollDirection.VERTICAL,}}ref={pdfRef}fragmentTag="PDF1"style={{flex: 1}}/>);}}The app is now ready to launch! Go back to the terminal app and run:
Terminal window npx react-native run-androidTerminal 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:
- React Native UI Component for Android
- React Native UI Component for iOS
- Advanced Techniques for React Native UI Components
- How to Extend React Native APIs
- How to Bridge Native iOS Code to React Native
- How to Open a PDF in React Native Using the Document Picker
- How to Build a React Native PDF Viewer