Skip to main content
Solana apps discover wallets by registration, not by probing for a provider object. @privy-io/cross-app-connect/solana registers a Privy global wallet as a Wallet Standard wallet, so existing @solana/wallet-adapter code picks it up with no custom adapter.

1. Install dependencies

Install the SDK and the Wallet Standard packages it requires:
The Wallet Standard packages are peer dependencies of the ./solana subpath.

2. Register the wallet

Call registerPrivyCrossAppWallet once, early in the app’s lifecycle:

Parameters

The function accepts an object with the following fields:
string
required
Privy app ID of the Solana global wallet provider.
string
required
Wallet name shown in a Wallet Standard app, such as a @solana/wallet-adapter wallet list.
WalletIcon
required
Wallet icon shown alongside name. Wallet Standard types this as a base64 data URI: data:image/svg+xml;base64,…, data:image/png;base64,…, data:image/webp;base64,…, or data:image/gif;base64,…. An ordinary HTTPS URL does not satisfy the type.
SolanaCaip2ChainId | SolanaChainInput
default:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
The Solana cluster, meaning the network such as mainnet or devnet, that scopes the connection. Defaults to mainnet.
'message' | 'redirect'
default:"message"
How the requester asks for its response. A headless provider built on @privy-io/cross-app-provider always replies over postMessage, so leave this at message to match.
string
Replaces the provider’s connect URL returned by the Privy API.
string
Replaces the provider’s transact URL returned by the Privy API.
number
default:"120000"
Milliseconds before a wallet request closes with a timeout error. Defaults to two minutes.
string
Overrides the default Privy API URL. Intended for local development against a non-default stack.

Returns

PrivyCrossAppSolanaWallet
The registered Wallet Standard wallet.
() => void
Removes the wallet from every registry that accepted it and stops listening for apps that initialize later.

3. Manage the registration lifecycle

Registration is a side effect on window, so pair it with cleanup. In React, register in a useEffect and return unregister:
A duplicate effect run is safe. At most one registration per provider app and cluster stays live. An app that accepts wallets from several providers calls registerPrivyCrossAppWallet once per provider app ID. Each registration keeps its own stored approval, and all of them appear in the wallet list below.

4. Wrap the app with providers

The wallet announces itself over the wallet-standard:register-wallet event and also answers apps that initialize after that event fires. WalletProvider therefore finds it without an entry in wallets:
Use autoConnect. The wallet responds as follows:
  • With no stored connection, the wallet answers a silent probe with an empty account list and opens no popup. Page load never surprises the user with a consent window.
  • With a stored connection, the wallet exposes its account immediately and autoConnect reconnects without a popup. Connections live in localStorage and the provider stamps them with a 14-day expiry.
  • The wallet clears an expired or malformed stored connection, leaving an empty account list. The next explicit connect opens the consent popup as usual.

Complete example

All together, this should look like:
Registration touches window, so it must run on the client. In the Next.js App Router, mark both files 'use client'.

5. Connect the wallet

useWallet lists every registered wallet. Selecting one connects it, which opens the provider’s consent popup:
select only records the choice: WalletProvider connects the selected wallet because autoConnect is set.

Accepted chain identifiers

Three forms name the same cluster. All normalize to the genesis-hash CAIP-2 ID, the chain-agnostic identifier format Privy sends on the wire. Any other value throws at registration. The wallet reports its cluster as the alias form through wallet.chains.