Appearance
Setting up your app with the Expo SDK
To set up your app with Privy's Expo SDK, follow the steps below:
1. Install the required dependencies
Core Dependencies
Install the Privy Expo SDK along with its peer dependencies using npm
:
sh
npx expo install expo-application expo-constants expo-web-browser expo-linking expo-secure-store react-native-webview expo-crypto @privy-io/expo
Polyfills
Install polyfills which account for APIs required by the Privy Expo SDK that are not available in the React Native environment.
sh
npm i --save fast-text-encoding react-native-get-random-values @ethersproject/shims
If your app uses the Expo bare workflow, the following must also be run.
sh
npx pod install
Polyfills must then be installed and imported as early as possible in your application.
TIP
Polyfills must be imported in the correct order to work properly.
tsx
import 'fast-text-encoding';
import 'react-native-get-random-values';
import '@ethersproject/shims';
// Your root component
2. Wrap your components with the PrivyProvider
To begin using the Expo SDK in your code, import the PrivyProvider
component from the SDK, and wrap the rest of your app's components with it.
As a prop to this component, you must specify an appId
which is your Privy App ID from the Privy dashboard.
tsx
// Import required polyfils first
import 'fast-text-encoding';
import 'react-native-get-random-values';
import '@ethersproject/shims';
import React from 'react';
// Import the PrivyProvider
import {PrivyProvider} from '@privy-io/expo';
// Your components
import {HomeScreen} from './Homescreen';
export default function App() {
return (
// Render the PrivyProvider with your app ID
<PrivyProvider appId={'insert-your-privy-app-id'}>
<HomeScreen />
</PrivyProvider>
);
}