Migrate from v2 to v3
Overview
Wagmi v3 gives you total control over connector dependencies. Since Wagmi's initial release, Wagmi included required connector dependencies as part of its package to eliminate the need to manage multiple third-party dependencies.
This worked worked well in the early years as a "batteries-included" approach, but didn't allow for more fine-grained control over your dependency tree. By giving you control over connector dependencies, you can decide to only install what you need, manage version bumps at your own pace, and have total control over what third-party code and licenses you bring into your project
To get started, install the latest version of Wagmi.
pnpm add wagmi@3npm install wagmi@3yarn add wagmi@3bun add wagmi@3Not ready to migrate yet?
The Wagmi v2 docs are still available at 2.x.wagmi.sh/react.
Install Connector Dependencies
All connector dependencies are now optional peer dependencies. This means that if you want to use a specific connector, you need to install its required dependencies.
For example, if you are using the porto connector, you also need to install the porto npm package. Required connector dependencies are listed below (along with links to npm, GitHub, Socket, and licenses) and on docs pages under the "Install" section.
Secure your supply-chain
Since you are now responsible for managing connector dependencies, take a look at Wagmi's Security Getting Started section to brush up on some best practices.
Building a developer tool on top of Wagmi?
If you are developing a library with Wagmi, you should decide if you want to install connector dependencies as part of your library ("batteries-included" approach) or pass the responsibility onto your users (more flexibility and control).
baseAccount
baseAccount requires @base-org/account
pnpm add @base-org/account@~2.4.0npm install @base-org/account@~2.4.0yarn add @base-org/account@~2.4.0bun add @base-org/account@~2.4.0coinbaseWallet
coinbaseWallet requires @coinbase/wallet-sdk
pnpm add @coinbase/wallet-sdk@~4.3.6npm install @coinbase/wallet-sdk@~4.3.6yarn add @coinbase/wallet-sdk@~4.3.6bun add @coinbase/wallet-sdk@~4.3.6gemini
gemini requires @gemini-wallet/core
pnpm add @gemini-wallet/core@~0.3.1npm install @gemini-wallet/core@~0.3.1yarn add @gemini-wallet/core@~0.3.1bun add @gemini-wallet/core@~0.3.1metaMask
metaMask requires @metamask/sdk
pnpm add @metamask/sdk@~0.33.1npm install @metamask/sdk@~0.33.1yarn add @metamask/sdk@~0.33.1bun add @metamask/sdk@~0.33.1porto
porto requires porto
pnpm add porto@~0.2.35npm install porto@~0.2.35yarn add porto@~0.2.35bun add porto@~0.2.35safe
safe requires @safe-global/safe-apps-provider and @safe-global/safe-apps-sdk
@safe-global/safe-apps-provider@safe-global/safe-apps-sdkpnpm add @safe-global/safe-apps-provider@~0.18.6 @safe-global/safe-apps-sdk@~9.1.0npm install @safe-global/safe-apps-provider@~0.18.6 @safe-global/safe-apps-sdk@~9.1.0yarn add @safe-global/safe-apps-provider@~0.18.6 @safe-global/safe-apps-sdk@~9.1.0bun add @safe-global/safe-apps-provider@~0.18.6 @safe-global/safe-apps-sdk@~9.1.0walletConnect
walletConnect requires @walletconnect/ethereum-provider
pnpm add @walletconnect/ethereum-provider@~2.21.1npm install @walletconnect/ethereum-provider@~2.21.1yarn add @walletconnect/ethereum-provider@~2.21.1bun add @walletconnect/ethereum-provider@~2.21.1Bumped Minimum TypeScript Version
The minimum supported TypeScript version is now 5.7.3 instead of 5.0.4. Older versions of TypeScript should continue to work, but since TypeScript doesn't follow semver we recommend you update to at least 5.7.3. This should be relatively simple as there haven't been any breaking changes since 5.0.4.
Migrate v2 Deprecations
v2 deprecations Review the v2 migration guide for more information.
Deprecations
Renamed Account Hooks
At the core of Wagmi are connections between apps and Ethereum providers (e.g. EIP-1193), useAccount, useAccountEffect, and useSwitchAccount are renamed to useConnection, useConnectionEffect, and useSwitchConnection to more accurately represent to how Wagmi works.
import {
useAccount,
useConnection,
useAccountEffect,
useConnectionEffect,
useSwitchAccount,
useSwitchConnection,
} from 'wagmi'Removed useConnect().connectors & useReconnect().connectors
Moving forward, useConnect().connectors and useReconnect().connectors are no longer supported. Use useConnectors instead.
import { useConnect, useReconnect } from 'wagmi'
import { useConnectors } from 'wagmi'
const { connectors } = useConnect()
const { connectors } = useReconnect()
const connectors = useConnectors()Removed useDisconnect().connectors & useSwitchConnection().connectors
Moving forward, useDisconnect().connectors and useSwitchConnection().connectors are no longer supported. Use useConnections instead.
import { useDisconnect, useSwitchConnection } from 'wagmi'
import { useConnections } from 'wagmi'
const { connectors } = useDisconnect()
const { connectors } = useSwitchConnection()
const connections = useConnections()
const connectors = connections.map((connection) => connection.connector)Removed useSwitchChain().chains
Moving forward, useSwitchChain().chains is no longer supported. Use useChains instead.
import { useSwitchChain } from 'wagmi'
import { useChains } from 'wagmi'
const { chains } = useSwitchChain()
const chains = useChains()