If your Expo mobile app uses Privy, you can implement wallet deeplinking to allow your users to connect their existing mobile wallets (like Phantom) with a seamless experience. This guide will walk you through the steps to set up wallet deeplinking in your Privy Expo app.
This guide assumes that you have already integrated Privy into your React native app. If you have not yet set up the basic integration, please first follow the Privy quickstart.
First, make sure you have the necessary dependencies:
Import the wallet connector hooks in your component:
Privy Expo provides several hooks for wallet deeplinking:
Hook | Description |
---|---|
useDeeplinkWalletConnector | A generic wallet deeplinking connector that you can configure for various wallets |
usePhantomDeeplinkWalletConnector | A pre-configured connector specifically for Phantom wallet |
useBackpackDeeplinkWalletConnector | A pre-configured connector specifically for Backpack wallet |
To set up the Phantom wallet connector, use the usePhantomDeeplinkWalletConnector
hook in your component:
The usePhantomDeeplinkWalletConnector
hook accepts the following configuration:
Parameter | Type | Description |
---|---|---|
appUrl | string | The URL of your app that will be displayed in the wallet app as the requesting dapp, for metadata purposes |
redirectUri | string | The path in your app that the wallet should redirect to after completing an action |
To set up the Phantom wallet connector, use the usePhantomDeeplinkWalletConnector
hook in your component:
The usePhantomDeeplinkWalletConnector
hook accepts the following configuration:
Parameter | Type | Description |
---|---|---|
appUrl | string | The URL of your app that will be displayed in the wallet app as the requesting dapp, for metadata purposes |
redirectUri | string | The path in your app that the wallet should redirect to after completing an action |
To set up the Backpack wallet connector, use the useBackpackDeeplinkWalletConnector
hook in your component:
The useBackpackDeeplinkWalletConnector
hook accepts the following configuration:
Parameter | Type | Description |
---|---|---|
appUrl | string | The URL of your app that will be displayed in the wallet app as the requesting dapp, for metadata purposes |
redirectUri | string | The path in your app that the wallet should redirect to after completing an action |
If you want to integrate with wallets other than Phantom or Backpack, you can use the generic useDeeplinkWalletConnector
hook and configure it for your specific wallet:
The generic useDeeplinkWalletConnector
hook accepts the following wallet-specific configuration parameters:
Parameter | Type | Description |
---|---|---|
baseUrl | string | The base URL for the wallet’s deeplink protocol. This is typically the wallet’s website URL or a custom URL scheme (e.g., https://solflare.com ). |
encryptionPublicKeyName | string | The name of the key in localStorage where the wallet stores its encryption public key. This is used for secure communication between your app and the wallet. |
appUrl | string | The URL of your app that will be displayed in the wallet app as the requesting dapp, for metadata purposes |
redirectUri | string | The path in your app that the wallet should redirect to after completing an action |
Always refer to the wallet provider’s documentation for the specific deeplink protocol implementation and required parameters. Each wallet may implement deeplinking differently and require specific configuration values.
Now you can implement UI components to interact with the wallet:
Here are examples of how to implement the handler functions for various wallet actions:
The configuration for the generic connector will depend on the specific wallet you’re integrating with. Refer to each wallet’s documentation for their deeplinking protocol.
When a user interacts with your app:
connect()
functionThis flow provides a seamless experience for users, allowing them to interact with your dApp using their preferred wallet without having to switch contexts or manually copy addresses.
That’s it! You’ve successfully integrated wallet deeplinking in your Privy React Native app 🎉
For the best user experience, consider implementing fallbacks for when a user doesn’t have the wallet installed. You might prompt them to install the wallet or offer them an alternative login method.
If your Expo mobile app uses Privy, you can implement wallet deeplinking to allow your users to connect their existing mobile wallets (like Phantom) with a seamless experience. This guide will walk you through the steps to set up wallet deeplinking in your Privy Expo app.
This guide assumes that you have already integrated Privy into your React native app. If you have not yet set up the basic integration, please first follow the Privy quickstart.
First, make sure you have the necessary dependencies:
Import the wallet connector hooks in your component:
Privy Expo provides several hooks for wallet deeplinking:
Hook | Description |
---|---|
useDeeplinkWalletConnector | A generic wallet deeplinking connector that you can configure for various wallets |
usePhantomDeeplinkWalletConnector | A pre-configured connector specifically for Phantom wallet |
useBackpackDeeplinkWalletConnector | A pre-configured connector specifically for Backpack wallet |
To set up the Phantom wallet connector, use the usePhantomDeeplinkWalletConnector
hook in your component:
The usePhantomDeeplinkWalletConnector
hook accepts the following configuration:
Parameter | Type | Description |
---|---|---|
appUrl | string | The URL of your app that will be displayed in the wallet app as the requesting dapp, for metadata purposes |
redirectUri | string | The path in your app that the wallet should redirect to after completing an action |
To set up the Phantom wallet connector, use the usePhantomDeeplinkWalletConnector
hook in your component:
The usePhantomDeeplinkWalletConnector
hook accepts the following configuration:
Parameter | Type | Description |
---|---|---|
appUrl | string | The URL of your app that will be displayed in the wallet app as the requesting dapp, for metadata purposes |
redirectUri | string | The path in your app that the wallet should redirect to after completing an action |
To set up the Backpack wallet connector, use the useBackpackDeeplinkWalletConnector
hook in your component:
The useBackpackDeeplinkWalletConnector
hook accepts the following configuration:
Parameter | Type | Description |
---|---|---|
appUrl | string | The URL of your app that will be displayed in the wallet app as the requesting dapp, for metadata purposes |
redirectUri | string | The path in your app that the wallet should redirect to after completing an action |
If you want to integrate with wallets other than Phantom or Backpack, you can use the generic useDeeplinkWalletConnector
hook and configure it for your specific wallet:
The generic useDeeplinkWalletConnector
hook accepts the following wallet-specific configuration parameters:
Parameter | Type | Description |
---|---|---|
baseUrl | string | The base URL for the wallet’s deeplink protocol. This is typically the wallet’s website URL or a custom URL scheme (e.g., https://solflare.com ). |
encryptionPublicKeyName | string | The name of the key in localStorage where the wallet stores its encryption public key. This is used for secure communication between your app and the wallet. |
appUrl | string | The URL of your app that will be displayed in the wallet app as the requesting dapp, for metadata purposes |
redirectUri | string | The path in your app that the wallet should redirect to after completing an action |
Always refer to the wallet provider’s documentation for the specific deeplink protocol implementation and required parameters. Each wallet may implement deeplinking differently and require specific configuration values.
Now you can implement UI components to interact with the wallet:
Here are examples of how to implement the handler functions for various wallet actions:
The configuration for the generic connector will depend on the specific wallet you’re integrating with. Refer to each wallet’s documentation for their deeplinking protocol.
When a user interacts with your app:
connect()
functionThis flow provides a seamless experience for users, allowing them to interact with your dApp using their preferred wallet without having to switch contexts or manually copy addresses.
That’s it! You’ve successfully integrated wallet deeplinking in your Privy React Native app 🎉
For the best user experience, consider implementing fallbacks for when a user doesn’t have the wallet installed. You might prompt them to install the wallet or offer them an alternative login method.