> ## Documentation Index
> Fetch the complete documentation index at: https://docs.privy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Wallet Standard connector

> Register a Solana global wallet so @solana/wallet-adapter code discovers it through Wallet Standard.

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](https://github.com/wallet-standard/wallet-standard) wallet, so existing [`@solana/wallet-adapter`](https://github.com/anza-xyz/wallet-adapter) code picks it up with no custom adapter.

## 1. Install dependencies

Install the SDK and the Wallet Standard packages it requires:

```bash theme={"system"}
npm i @privy-io/cross-app-connect @solana/wallet-adapter-react @solana/web3.js @solana/wallet-standard-features @wallet-standard/base @wallet-standard/features
```

The Wallet Standard packages are peer dependencies of the `./solana` subpath.

## 2. Register the wallet

Call `registerPrivyCrossAppWallet` once, early in the app's lifecycle:

```tsx theme={"system"}
import {registerPrivyCrossAppWallet} from '@privy-io/cross-app-connect/solana';

const {wallet, unregister} = registerPrivyCrossAppWallet({
  providerAppId: 'clq4ktn2s0008pjq97k77ixav',
  name: 'Abstract',
  icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0i...'
});
```

### Parameters

The function accepts an object with the following fields:

**providerAppId** `string` *required*

Privy app ID of the Solana global wallet provider.

**name** `string` *required*

Wallet name shown in a Wallet Standard app, such as a `@solana/wallet-adapter` wallet list.

**icon** `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.

**chain** `SolanaCaip2ChainId | SolanaChainInput` (default: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp)

The Solana cluster, meaning the network such as mainnet or devnet, that scopes the connection.
Defaults to mainnet.

**communicationMode** `'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.

**overrideConnectUrl** `string`

Replaces the provider's connect URL returned by the Privy API.

**overrideTransactUrl** `string`

Replaces the provider's transact URL returned by the Privy API.

**defaultPopupTimeout** `number` (default: 120000)

Milliseconds before a wallet request closes with a timeout error. Defaults to two minutes.

**apiUrl** `string`

Overrides the default Privy API URL. Intended for local development against a non-default stack.

### Returns

**wallet** `PrivyCrossAppSolanaWallet`

The registered Wallet Standard wallet.

**unregister** `() =\> 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`:

```tsx theme={"system"}
import {useEffect} from 'react';
import {registerPrivyCrossAppWallet} from '@privy-io/cross-app-connect/solana';

function PrivyWalletRegistration() {
  useEffect(() => {
    const {unregister} = registerPrivyCrossAppWallet({
      providerAppId: 'clq4ktn2s0008pjq97k77ixav',
      name: 'Abstract',
      icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0i...'
    });

    return unregister;
  }, []);

  return null;
}
```

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`:

```tsx theme={"system"}
import {ConnectionProvider, WalletProvider} from '@solana/wallet-adapter-react';
import {clusterApiUrl} from '@solana/web3.js';

function Providers({children}: {children: React.ReactNode}) {
  return (
    <ConnectionProvider endpoint={clusterApiUrl('mainnet-beta')}>
      <PrivyWalletRegistration />
      <WalletProvider wallets={[]} autoConnect>
        {children}
      </WalletProvider>
    </ConnectionProvider>
  );
}
```

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:

**privy-wallet.tsx**

```tsx theme={"system"}
import {useEffect} from 'react';
import {registerPrivyCrossAppWallet} from '@privy-io/cross-app-connect/solana';

export function PrivyWalletRegistration() {
  useEffect(() => {
    const {unregister} = registerPrivyCrossAppWallet({
      providerAppId: 'clq4ktn2s0008pjq97k77ixav',
      name: 'Abstract',
      icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0i...'
    });

    return unregister;
  }, []);

  return null;
}
```

**providers.tsx**

```tsx theme={"system"}
import {ConnectionProvider, WalletProvider} from '@solana/wallet-adapter-react';
import {clusterApiUrl} from '@solana/web3.js';

import {PrivyWalletRegistration} from './privy-wallet';

export function Providers({children}: {children: React.ReactNode}) {
  return (
    <ConnectionProvider endpoint={clusterApiUrl('mainnet-beta')}>
      <PrivyWalletRegistration />
      <WalletProvider wallets={[]} autoConnect>
        {children}
      </WalletProvider>
    </ConnectionProvider>
  );
}
```

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:

```tsx theme={"system"}
import {useWallet} from '@solana/wallet-adapter-react';

export function ConnectWallet() {
  const {wallets, select, publicKey, disconnect} = useWallet();

  if (publicKey) {
    return <button onClick={disconnect}>Disconnect {publicKey.toBase58()}</button>;
  }

  return (
    <>
      {wallets.map(({adapter}) => (
        <button key={adapter.name} onClick={() => select(adapter.name)}>
          Connect {adapter.name}
        </button>
      ))}
    </>
  );
}
```

`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](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md) ID, the chain-agnostic identifier format Privy sends on the wire.

| Cluster | CAIP-2 genesis hash | Wallet Standard alias | REST API alias |
| - | - | - | - |
| Mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | `solana:mainnet` | `solana_mainnet` |
| Devnet | `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1` | `solana:devnet` | `solana_devnet` |
| Testnet | `solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z` | `solana:testnet` | `solana_testnet` |

Any other value throws at registration. The wallet reports its cluster as the alias form through `wallet.chains`.
