Nutrient React Native SDK 3 migration guide
Older versions available: If you don’t want to migrate your project to version 3 yet, older versions can still be accessed using the standard GitHub URL. For version 2.19.1, use the following in your package.json
file: "react-native-pspdfkit": "github:PSPDFKit/react-native#2.19.1"
This guide covers migrating to Nutrient React Native SDK 3. This release includes a new package name and updated component and API names to match our new branding.
Package name
Nutrient React Native SDK’s package has changed to @nutrient-sdk/react-native
. Update your application’s package.json
file to reference the new package, which is now also available from npmjs.com:
"react-native-pspdfkit": "github:PSPDFKit/react-native","@nutrient-sdk/react-native": "~3.0.0",
To prevent duplicate type errors, you’ll be required to uninstall the old @nutrient-sdk/react-native
package completely and install the new package. It’s usually also a good idea to remove your node_modules
directory and install your dependencies again using yarn install
or npm install
.
Due to the new package name, all import statements will need to be updated to point at the new package name — for example:
import PSPDFKitView, { NotificationCenter } from 'react-native-pspdfkit';import NutrientView, { NotificationCenter } from '@nutrient-sdk/react-native';
Component and APIs
The main component to use in your implementation has been renamed from PSPDFKitView
to NutrientView
:
<PSPDFKitView <NutrientView document={DOCUMENT} configuration={{ showThumbnailBar: 'scrollable', pageTransition: 'scrollContinuous', scrollDirection: 'vertical' }} ref={pdfRef} fragmentTag="PDF1" style={{flex: 1}}/>
The main native module that hosts some of the core APIs has been renamed from PSPDFKit
to Nutrient
:
export const PSPDFKit = NativeModules.PSPDFKit;export const Nutrient = NativeModules.Nutrient;
PSPDFKit.setLicenseKey("YOUR_LICENSE_KEY");Nutrient.setLicenseKey("YOUR_LICENSE_KEY");
Native dependencies
After rebranding to Nutrient, our Maven dependency URL also changed. In your application’s build.gradle
file found inside the android
directory, apply the following update:
allprojects { repositories { google() mavenLocal() mavenCentral() maven { url 'https://my.pspdfkit.com/maven/' url 'https://my.nutrient.io/maven/' } }}
Since the 2.8 release, the iOS dependency has been managed by the React Native SDK, but if you’re still importing the SDK inside your application’s Podfile, update the URLs:
pod "PSPDFKit", podspec: "https://my.pspdfkit.com/pspdfkit-ios/nightly.podspec"pod "Instant", podspec: "https://my.pspdfkit.com/instant/latest.podspec"
pod "PSPDFKit", podspec: "https://my.nutrient.io/pspdfkit-ios/nightly.podspec" pod "Instant", podspec: "https://my.nutrient.io/instant/nightly.podspec"
For more information, refer to the Nutrient React Native SDK 3 changelog.