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

# Migrate from Web3Modal v5 to Reown AppKit Solana

# Upgrade Guide

## Web3Modal v5 to Reown AppKit - Web | Solana

This guide will help you migrate from Web3Modal v5 using Solana to the latest Reown AppKit.

**Find here all the upgrades guides:**

* [To Reown Web AppKit using Wagmi](/appkit/upgrade/to-reown-appkit-web).
* [To Reown Web AppKit using Ethers](/appkit/upgrade/to-reown-appkit-ethers-web).
* [To Reown Web AppKit using Ethers v5](/appkit/upgrade/to-reown-appkit-ethers5-web).

### Installation

To upgrade from Web3Modal v5 to Reown AppKit, start by removing the Web3Modal v5 dependency `@web3modal/solana`.

<CodeGroup>
  ```bash npm theme={null}
  npm uninstall @web3modal/solana
  ```

  ```bash Yarn theme={null}
  yarn remove @web3modal/solana
  ```

  ```bash Bun theme={null}
  bun remove @web3modal/solana
  ```

  ```bash pnpm theme={null}
  pnpm remove @web3modal/solana
  ```
</CodeGroup>

Next, install the Reown AppKit and Solana wallet adapter packages.

<CodeGroup>
  ```bash npm theme={null}
  npm install @reown/appkit @reown/appkit-adapter-solana
  ```

  ```bash Yarn theme={null}
  yarn add @reown/appkit @reown/appkit-adapter-solana 
  ```

  ```bash Bun theme={null}
  bun a @reown/appkit @reown/appkit-adapter-solana
  ```

  ```bash pnpm theme={null}
  pnpm add @reown/appkit @reown/appkit-adapter-solana
  ```
</CodeGroup>

### Implementation

<Tabs>
  <Tab title="React">
    Make sure you update the imports in your codebase to reflect the new package names.

    ```tsx {4-9} theme={null}
    // Remove the following imports
    - import { createWeb3Modal, defaultSolanaConfig, useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/solana/react'
    - import { solana, solanaTestnet, solanaDevnet } from '@web3modal/solana/chains'

    // Add the following imports
    + import { solana, solanaTestnet, solanaDevnet } from '@reown/appkit/networks'
    + import { createAppKit } from '@reown/appkit/react'
    + import { SolanaAdapter } from '@reown/appkit-adapter-solana/react'
    ```

    Now, set up the Solana Adapter and the modal.

    The `chains` property is now `networks` in Reown AppKit. You should import them from `@reown/appkit/networks` package instead of importing these networks other packages.

    The `metadata` and the `projectId` are the same as before.

    ```tsx {5-15} theme={null}
    // Remove the following code lines
    - const solanaConfig = defaultSolanaConfig({ ... });
    - createWeb3Modal( ... );

    // Add the following code lines
    + const solanaAdapter = new SolanaAdapter()

    + const modal = createAppKit({
    +   projectId,
    +   metadata,
    +   networks: [solana, solanaTestnet, solanaDevnet],
    +   adapters: [solanaAdapter],
    + })
    ```
  </Tab>

  <Tab title="Vue">
    Make sure you update the imports in your codebase to reflect the new package names.

    ```tsx {4-13} theme={null}
    // Remove the following imports
    - import { createWeb3Modal, defaultSolanaConfig, useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/solana/vue'
    - import { solana, solanaTestnet, solanaDevnet } from '@web3modal/solana/chains'

    // Add the following imports
    + import { solana, solanaTestnet, solanaDevnet } from '@reown/appkit/networks'
    + import { createAppKit } from '@reown/appkit/vue'
    + import { SolanaAdapter } from '@reown/appkit-adapter-solana/vue'
    ```

    Now, set up the Solana Adapter and the modal.

    The `chains` property is now `networks` in Reown AppKit. You should import them from `@reown/appkit/networks` package instead of importing these networks other packages.

    The `metadata` and the `projectId` are the same as before.

    ```tsx {5-15} theme={null}
    // Remove the following code lines
    - const solanaConfig = defaultSolanaConfig({ ... });
    - createWeb3Modal( ... );

    // Add the following code lines
    + const solanaAdapter = new SolanaAdapter()

    + const modal = createAppKit({
    +   projectId,
    +   metadata,
    +   networks: [solana, solanaTestnet, solanaDevnet],
    +   adapters: [solanaAdapter],
    + })
    ```
  </Tab>

  <Tab title="JavaScript">
    Make sure you update the imports in your codebase to reflect the new package names.

    ```tsx {5-8} theme={null}
    // Remove the following imports
    - import { createWeb3Modal, defaultSolanaConfig, useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/solana/react'
    - import { solana, solanaTestnet, solanaDevnet } from '@web3modal/solana/chains'

    // Add the following imports
    + import { solana, solanaTestnet, solanaDevnet } from '@reown/appkit/networks'
    + import { createAppKit } from '@reown/appkit'
    + import { SolanaAdapter } from '@reown/appkit-adapter-solana'
    ```

    Now, set up the Solana Adapter and the modal.

    The `chains` property is now `networks` in Reown AppKit. You should import them from `@reown/appkit/networks` package instead of importing these networks other packages.

    The `metadata` and the `projectId` are the same as before.

    ```tsx {5-15} theme={null}
    // Remove the following code lines
    - const solanaConfig = defaultSolanaConfig({ ... });
    - createWeb3Modal( ... );

    // Add the following code lines
    + const solanaAdapter = new SolanaAdapter()

    + const modal = createAppKit({
    +   projectId,
    +   metadata,
    +   networks: [solana, solanaTestnet, solanaDevnet],
    +   adapters: [solanaAdapter],
    + })
    ```
  </Tab>
</Tabs>

### Trigger the modal

<Tabs>
  <Tab title="React">
    ```tsx {4-10} theme={null}
    // Remove the following code line
    - import { useWeb3Modal } from '@web3modal/wagmi/react'

    // Add the following code lines
    + import { useAppKit } from '@reown/appkit/react'
    function HomePage() {
      const { open } = useAppKit()
      return <button onClick={open}>Connect</button>
    }
    ```

    Learn more about Reown AppKit [here](../react/core/installation)
  </Tab>

  <Tab title="Vue">
    Use your own button with to open the modal

    ```js theme={null}
    document.getElementById('my-button').addEventListener('click', () => {
        modal.open()
    })

    <button id="my-button">Connect Wallet</button>
    ```

    Learn more about Reown AppKit JavaScript [here](../javascript/core/installation)
  </Tab>

  <Tab title="JavaScript">
    Use your own button with to open the modal

    ```js theme={null}
    document.getElementById('my-button').addEventListener('click', () => {
        modal.open()
    })

    <button id="my-button">Connect Wallet</button>
    ```

    Learn more about Reown AppKit JavaScript [here](../javascript/core/installation)
  </Tab>
</Tabs>

### Properties

As you may have noticed, some of the properties of Web3Modal have changed as a consequence of the migration to Reown AppKit.

#### adapters

The `adapters` property is a new property that is an array of adapters that can be initialized.

#### networks

The `chains` property is now `networks` in Reown AppKit. You should import them from `@reown/appkit/networks` package instead of importing these networks from `viem` or other packages.

#### defaultNetwork

The `defaultChain` property is now `defaultNetwork` in Reown AppKit. This is a network object that specifies the default network for your Web3 app.

### Utility Functions

The following methods are still available with the same nomenclature as before:

#### modal.getAddress()

This returns the connected address.

<Info>
  It returns the active namespace's address.

  **Example**: You’ve initialized both the Wagmi and Solana adapters and connected to a dApp with an EVM-only wallet (e.g., Rainbow). In this case, the Solana adapter is still not connected. When your active network is one of the EVM chains, the address will return your wallet address. However, if you manually switch to the Solana network, the address will return `undefined` (unless you connect to a Solana wallet).
</Info>

#### modal.getError()

This returns the error values.

#### modal.getChainId()

Returns the active network's `chainId`

<Info>
  In versions prior to v5, which were single-chain, `getChainId()` returned a single type rather than multiple types:

  * `@web3modal/wagmi` (along with ethers and ethers5) returned `number | undefined`.
  * `@web3modal/solana` returned `string | undefined`.

  Now, in Reown AppKit, since both chains can be connected simultaneously, the type definition is `number | string | undefined`.
</Info>

#### modal.switchNetwork(network)

This switches the active network to the different network being passed.

<Info>
  Unlike in v5, `modal.switchNetwork` takes the chain object as parameter rather than the chain id.

  * (v5) - switchNetwork(103) -> switches the chain to Solana Devnet as we are passing Solana Devnet's chain id.
  * (Reown AppKit v1) - switchNetwork(solanaDevnet) -> `solanaDevnet` is imported from `@reown/appkit/networks`.

  ```tsx {4-7} theme={null}
  // Remove the following code line
  modal.switchNetwork(103);

  // Add the following code lines
  import { solanaDevnet } from "@reown/appkit/networks";
  modal.switchNetwork(solanaDevnet);
  ```
</Info>

#### modal.getIsConnected()

This returns if the selected network adapter is connected or not.

<Info>
  It returns the active namespace's connection status as a boolean.

  Example: You've initialized both the Wagmi and Solana adapters and connected to the dApp with an EVM-only wallet (e.g., Rainbow). In this case, the Solana adapter is still not connected. When you manually switch to the Solana network from the network selection list, you will see a disconnected state because the Solana adapter cannot use Rainbow's connection. As a result, it will prompt you to connect with a Solana wallet.
</Info>

#### modal.getWalletProvider()

This returns the active connection provider.

#### modal.getWalletProviderType()

This returns the active connection provider type.

#### modal.subscribeProvider(callback)

This is a listener that detects changes to the AppKit state, such as `address`, `chainId`, `isConnected`, `provider`, and `providerType`.

* `address` - It returns the connected wallet address. The value returned is the same as `modal.getAddress()`
* `chainId` - It returns the active network’s `chainId` . The value returned is the same as `modal.getChainId()`
* `isConnected` - It returns if the selected network adapter is connected. The value returned is the same as `modal.getIsConnected()`
* `provider` - It returns the active connection provider. The value returned is the same as `modal.getWalletProvider()`
* `providerType` - It returns the active connection provider type. The value returned is the same as `modal.getWalletProviderType()`

The following methods and listeners are exactly the same and do not have any specific details related to the multiple chains feature.

* `modal.getState` - it returns the modal state
  * `open` - it returns boolean that indicates if the modal is open or not
  * `selectedNetworkId` - it returns active network’s id
* `modal.subscribeState`
* `modal.setThemeMode`
* `modal.getThemeMode`
* `modal.setThemeVariables`
* `modal.getThemeVariables`
* `modal.subscribeTheme`
* `modal.getEvent`
* `modal.subscribeEvents`
