Skip to content

Integrating a wallet from another app

Privy allows you to easily integrate embedded wallets from other apps, to verify ownership of users' wallet addresses or even request signatures and transactions from.

This reduces friction around having users transact onchain in your app, as users can easily pull in their assets and identity from other apps where they may already have embedded wallets.

Within this setup, your app is known as the requester app.

Finding available providers

To integrate embedded wallets from another app, first visit the Privy Dashboard and navigate to the Ecosystem page for your app. From there, open the Integrations tab to see a list of provider app IDs that consent to sharing their wallets with other apps.

For any providers you'd like to integrate, note down the provider's Privy app ID, as you will use this value in the interfaces outlined below.

TIP

Some providers may only consent to sharing their users' wallets in read-only mode, in which case your app can verify that the user owns a particular address, but cannot request signatures or transactions from it.

Logging in with an account from a provider

Headlessly

To prompt users to log into your app with an account from a provider app, use the loginWithCrossApp method from the useLoginWithCrossApp hook:

tsx
const {loginWithCrossApp} = useLoginWithCrossApp();

As a parameter to this method, pass an object containing the following fields:

ParameterTypeDescription
appIdstringThe Privy app ID of the provider app from which you'd like a user to link their account. You can find a list of Privy app IDs for provider apps in the Cross-app ecosystem page of the Privy Dashboard.
redirectUristring(Optional) A URL path that the provider will automatically redirect to after successful authentication. This defaults to a link back to your app root, eg. '/', if not provided.

When loginWithCrossApp is invoked, an in-app browser will open for a page hosted on the domain of the provider app you specified to authorize access to your own app.

If the user successfully authorizes access, the user will be redirected back to your app, and an account of type: 'cross_app' will be added to the linked_accounts array of their user object.

loginWithCrossApp will throw an error if:

  • The user does not authorize access to your app or exits the flow prematurely.
  • The provider app you request has not opted-in to share their wallets.
  • The user does not already have an account with the provider app.

TIP

If the user is already logged in on the domain of the target appId you specify in loginWithCrossApp, they will not have to login again and will only have to consent to sharing access to that account in your app.

As an example, you might set up a button to link a cross-app wallet like so:

tsx
import {usePrivy, useLoginWithCrossApp} from '@privy-io/expo';

function LoginWithCrossAppButton() {
  const {ready, user} = usePrivy();
  const {loginWithCrossApp} = useLoginWithCrossApp();

  return (
    <Button
      onPress={() => loginWithCrossApp({appId: 'insert-provider-app-id'})}
      disabled={!ready || !!user}
    >
      Log in with [insert-provider-app-name]
    </Button>
  );
}

Linking a wallet from a provider

To prompt users to link their embedded wallet from a provider app, use the linkWithCrossApp method from the useLinkWithCrossApp hook:

tsx
const {linkWithCrossApp} = useLinkWithCrossApp();

As a parameter to this method, pass an object containing the following fields:

ParameterTypeDescription
appIdstringThe Privy app ID of the provider app from which you'd like a user to link their account. You can find a list of Privy app IDs for provider apps in the Cross-app ecosystem page of the Privy Dashboard.
redirectUristring(Optional) A URL path that the provider will automatically redirect to after successful authentication. This defaults to a link back to your app root, eg. '/', if not provided.

When linkWithCrossApp is invoked, the user will be redirected to a page hosted on the domain of the provider app you specified to authorize access to your own app.

If the user successfully authorizes access, the user will be redirected back to your app, and an account of type: 'cross_app' will be added to the linked_accounts array of their user object.

linkWithCrossApp will throw an error if:

  • The user does not authorize access to your app or exits the flow prematurely.
  • The provider app you request has not opted-in to share their wallets.
  • The user is not authenticated and thus cannot link an account from the provider app to an existing account within your requester's app.

As an example, you might set up a button to link a cross-app wallet like so:

tsx
import {usePrivy, useLinkWithCrossApp} from '@privy-io/expo';

function LinkWithCrossAppButton() {
  const {ready, user} = usePrivy();
  const {linkWithCrossApp} = useLinkWithCrossApp();

  return (
    <Button
      onPess={() => linkWithCrossApp({appId: 'insert-provider-app-id'})}
      disabled={!ready || !!user}
    >
      Link your [insert-provider-app-name] account
    </Button>
  );
}