This guide will help you migrate from Web3Modal v5 using ethers to the latest Reown AppKit.
Find here all the upgrades guides:
To upgrade from Web3Modal v5 to Reown AppKit, start by removing the Web3Modal v5 dependency @web3modal/ethers
.
Next, install the Reown AppKit packages.
You can start the AppKit configuration by using either the default or advanced mode.
Default mode will implement WalletConnect, Browser Wallets (injected) and Coinbase options in addition to WalletConnect’s provider.
Make sure to set your configuration outside React components to avoid unwanted rerenders.
Start by importing createAppKit
from @reown/appkit
and the necessary chains from @reown/appkit/networks
Then, remove the defaultConfig
function that is being imported from the Ethers package in your code.
Finally, set up the EthersAdapter
and pass the other parameters to createAppKit
function.
You can start the AppKit configuration by using either the default or advanced mode.
Default mode will implement WalletConnect, Browser Wallets (injected) and Coinbase options in addition to WalletConnect’s provider.
Make sure to set your configuration outside React components to avoid unwanted rerenders.
Start by importing createAppKit
from @reown/appkit
and the necessary chains from @reown/appkit/networks
Then, remove the defaultConfig
function that is being imported from the Ethers package in your code.
Finally, set up the EthersAdapter
and pass the other parameters to createAppKit
function.
You can start the AppKit configuration by using either the default or advanced mode.
Default mode will implement WalletConnect, Browser Wallets (injected) and Coinbase options in addition to WalletConnect’s provider.
Make sure to set your configuration outside React components to avoid unwanted rerenders.
Start by importing createAppKit
from @reown/appkit
and the necessary chains from @reown/appkit/networks
Then, remove the defaultConfig
function that is being imported from the Ethers package in your code.
Finally, set up the EthersAdapter
and pass the other parameters to createAppKit
function.
Start by importing AppKit packages, then create EthersAdapter using your own settings or the default presets as shown below.
Import createAppKit
from @reown/appkit
and the necessary chains from @reown/appkit/networks
Then, remove the defaultConfig
function that is being imported from the Ethers package in your code.
Finally, set up the EthersAdapter
and pass the other parameters to createAppKit
function.
Learn more about Reown AppKit here
As you may have noticed, some of the properties of Web3Modal have changed as a consequence of the migration to Reown AppKit.
The adapters
property is a new property that is an array of adapters that can be initialized.
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.
The defaultChain
property is now defaultNetwork
in Reown AppKit. This is a network object that specifies the default network for your Web3 app.
The following methods are still available with the same nomenclature as before:
This returns the connected address.
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).
This returns the error values.
Returns the active network’s chainId
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
.
This switches the active network to the different network being passed.
Unlike in v5, modal.switchNetwork
takes the chain object as parameter rather than the chain id.
polygon
is imported from @reown/appkit/networks
.This returns if the selected network adapter is connected or not.
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.
This returns the active connection provider.
This returns the active connection provider type.
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 notselectedNetworkId
- it returns active network’s idmodal.subscribeState
modal.setThemeMode
modal.getThemeMode
modal.setThemeVariables
modal.getThemeVariables
modal.subscribeTheme
modal.getEvent
modal.subscribeEvents
This guide will help you migrate from Web3Modal v5 using ethers to the latest Reown AppKit.
Find here all the upgrades guides:
To upgrade from Web3Modal v5 to Reown AppKit, start by removing the Web3Modal v5 dependency @web3modal/ethers
.
Next, install the Reown AppKit packages.
You can start the AppKit configuration by using either the default or advanced mode.
Default mode will implement WalletConnect, Browser Wallets (injected) and Coinbase options in addition to WalletConnect’s provider.
Make sure to set your configuration outside React components to avoid unwanted rerenders.
Start by importing createAppKit
from @reown/appkit
and the necessary chains from @reown/appkit/networks
Then, remove the defaultConfig
function that is being imported from the Ethers package in your code.
Finally, set up the EthersAdapter
and pass the other parameters to createAppKit
function.
You can start the AppKit configuration by using either the default or advanced mode.
Default mode will implement WalletConnect, Browser Wallets (injected) and Coinbase options in addition to WalletConnect’s provider.
Make sure to set your configuration outside React components to avoid unwanted rerenders.
Start by importing createAppKit
from @reown/appkit
and the necessary chains from @reown/appkit/networks
Then, remove the defaultConfig
function that is being imported from the Ethers package in your code.
Finally, set up the EthersAdapter
and pass the other parameters to createAppKit
function.
You can start the AppKit configuration by using either the default or advanced mode.
Default mode will implement WalletConnect, Browser Wallets (injected) and Coinbase options in addition to WalletConnect’s provider.
Make sure to set your configuration outside React components to avoid unwanted rerenders.
Start by importing createAppKit
from @reown/appkit
and the necessary chains from @reown/appkit/networks
Then, remove the defaultConfig
function that is being imported from the Ethers package in your code.
Finally, set up the EthersAdapter
and pass the other parameters to createAppKit
function.
Start by importing AppKit packages, then create EthersAdapter using your own settings or the default presets as shown below.
Import createAppKit
from @reown/appkit
and the necessary chains from @reown/appkit/networks
Then, remove the defaultConfig
function that is being imported from the Ethers package in your code.
Finally, set up the EthersAdapter
and pass the other parameters to createAppKit
function.
Learn more about Reown AppKit here
As you may have noticed, some of the properties of Web3Modal have changed as a consequence of the migration to Reown AppKit.
The adapters
property is a new property that is an array of adapters that can be initialized.
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.
The defaultChain
property is now defaultNetwork
in Reown AppKit. This is a network object that specifies the default network for your Web3 app.
The following methods are still available with the same nomenclature as before:
This returns the connected address.
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).
This returns the error values.
Returns the active network’s chainId
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
.
This switches the active network to the different network being passed.
Unlike in v5, modal.switchNetwork
takes the chain object as parameter rather than the chain id.
polygon
is imported from @reown/appkit/networks
.This returns if the selected network adapter is connected or not.
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.
This returns the active connection provider.
This returns the active connection provider type.
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 notselectedNetworkId
- it returns active network’s idmodal.subscribeState
modal.setThemeMode
modal.getThemeMode
modal.setThemeVariables
modal.getThemeVariables
modal.subscribeTheme
modal.getEvent
modal.subscribeEvents