Setup
Prerequisites
Before you begin, make sure you have set up your Privy app and obtained your app ID and client ID from the Privy Dashboard.
A properly set up app client is required for mobile apps and other non-web platforms to allow your app to interact with the Privy API. Please follow this guide to configure an app client by following this guide here.
Initializing Privy
In your project, import the PrivyProvider
component and wrap your app with it.
The PrivyProvider
must wrap any component or page that will use the Privy React Native SDK, and it is generally recommended to render it as close to the root of your application as possible.
Wrap your app with the PrivyProvider
in the app/_layout.tsx
file.
Configuration
The PrivyProvider
component accepts the following props:
Your Privy App ID. You can find this in the Privy Dashboard.
Your Privy Client ID. You can find this in the Privy Dashboard.
Waiting for Privy to be ready
When the PrivyProvider
is first rendered, the Privy SDK will initialize some state about the current user. This might include checking if the user has a wallet connected, refreshing expired auth tokens, fetching up-to-date user data, and more.
It’s important to wait until the PrivyProvider
has finished initializing before you consume Privy’s state and interfaces, to ensure that the state you consume is accurate and not stale.
To determine whether the Privy SDK has fully initialized, check the ready
Boolean returned by the usePrivy
hook. When ready
is true, Privy has completed initialization, and your app can consume Privy’s state and interfaces.
Was this page helpful?