Requirements
- A React Native project using the latest version
- iOS and Android platform support (Web is not supported)
- A development build with the New Architecture enabled. The SDK depends on native modules, so it does not run in Expo Go.
Installation
Core Dependencies
Install the Privy React Native SDK and its peer dependencies:For fine-grained control over your project’s dependencies, React Native 0.81+ (or Expo SDK 54+)
allows you to omit the following optional packages if you are not utilizing their corresponding
features:
expo-apple-authenticationfor native Sign in with Applereact-native-passkeysfor passkey authentication@privy-io/expo-native-extensionsfor iCloud recovery
Configure polyfills
Privy’s polyfills install WebCrypto (crypto.getRandomValues, crypto.randomUUID, and crypto.subtle) from react-native-quick-crypto. Import them before any other module, so that every library sees them when it loads.
- Using expo/router
- Without expo/router
Create an
entrypoint.js file and update your package.json:entrypoint.js
package.json
The polyfills only fill in what is missing. An existing WebCrypto setup, such as your app’s own
react-native-quick-crypto install(), is kept, and the polyfills never set Buffer.Upgrading from earlier versions
Earlier versions of the SDK requiredexpo-crypto, fast-text-encoding, react-native-get-random-values, and @ethersproject/shims. To upgrade, install react-native-quick-crypto, react-native-nitro-modules, and react-native-quick-base64, then rebuild your app. The existing polyfill setup keeps working.
Replace those polyfill imports with import '@privy-io/expo/polyfills' to get the full crypto API, and remove the packages if nothing else in your app uses them.
Testing with Jest
react-native-quick-crypto (1.1.8 or later) ships a mock for Jest. Add it to your Jest setup file:
Metro build configuration
Metro build configuration
This guide ensures that your application satisfies the following requirements for integrating:Update your
- uses an expo development build.
- has a custom
metro.config.jsfile to customize the Metro bundler settings - enables package exports for the Metro bundler:
- uses the
bundlersetting for Typescript’smoduleResolution
Enabling Package Exports
React Native 0.79, and Expo 53, have enabled package exports by default.Some popular packages present incompatibilities with this change, and the community is working to get these fixed at source.
In the meantime, we present a fix below by disabling package exports for the incompatibilities we have found.
metro.config.js like so:Typescript’s Module Resolution
Also configure yourtsconfig.json like so:
