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.Initializing Privy
In your project, import thePrivyProvider 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.
- Using expo/router
- Without expo/router
Wrap your app with the
Protect routes with
Setting up In the You must provide the following props to
PrivyProvider in the app/_layout.tsx file.Protect routes with AuthBoundary
Protect routes with AuthBoundary
Protect routes with AuthBoundary
Setting up PrivyProvider is all you need to use the Privy React Native SDK throughout your app! But if you want to protect certain routes, we recommend you do so by using the AuthBoundary component, as follows:Start by setting up a route group, like (app)/, under your app/ directory. Routes placed under this group will be protected by the AuthBoundary component, so only authenticated users can access them.(app)/_layout.tsx file, wrap the Stack component with the AuthBoundary component:AuthBoundary:loadinganderrorare both custom components that you can define to show specific UIs during the loading and error states.- On
unauthenticated, you should redirect the user to the sign in page, as defined above!
AuthBoundary, take a look at Expo Router’s docs on Authentication.Configuration
ThePrivyProvider component accepts the following props:
string
required
Your Privy App ID. You can find this in the Privy Dashboard.
string
required
Your Privy Client ID. You can find this in the Privy Dashboard.
Waiting for Privy to be ready
WhenPrivyProvider first renders, Privy restores the prior session and initializes the embedded wallet. Initialization can refresh auth tokens and fetch up-to-date user data.
Use isReady from usePrivy to await initialization completion. Your app can use it to gate user reads and wallet operations. The rest of the app can render immediately.
Reading user before isReady can show stale auth state. Wallet calls before isReady can throw.
isReady already includes embedded wallet initialization. Expo apps should not wait on a separate useWallets ready flag.
Quickstart Guide
Learn how to log users in and
transact with embedded wallets
Example Repo
Check out our Expo starter
repo for a complete example

