- A configured Dynamic client with the EVM extension added.
- EVM chains enabled in the Dynamic dashboard.
Scenario 1: Desktop — Extension installed
When the MetaMask browser extension is installed, it announces itself via EIP-6963 and the SDK registers it as a wallet provider. Connect directly through the provider — no QR code or deeplink needed.Detect the extension
UsegetMetaMaskEvmExtensionWalletProviderKey to check whether MetaMask is available as a browser extension. It returns the wallet provider key (e.g. 'metamaskevm') when installed, or undefined when not.
Connect and verify
Pass the detected key toconnectAndVerifyWithWalletProvider. This opens the MetaMask extension popup, the user approves the connection, then signs a verification message — all in one call.
Scenario 2: Desktop — No extension (QR code)
When MetaMask isn’t installed as a browser extension, use the MetaMask SDK URI pairing. This generates a URI that you render as a QR code. The user scans it with the MetaMask mobile app, approves the connection, and your dapp receives the wallet account.Connect and verify
connectAndVerifyWithMetaMaskUriEvm returns { uri, approval }. Render uri as a QR code; approval() resolves after the user approves the connection and signs the verification message in their MetaMask mobile app.
Connect without verifying
If you want to defer verification, useconnectWithMetaMaskUriEvm instead:
Clear stale sessions
If the user previously connected via QR and the session expired, the MetaMask SDK may spend up to 10 seconds trying to resume it before emitting a fresh URI. CallclearMetaMaskSessionStorage before starting a new pairing to skip the resume timeout:
Scenario 3: Mobile — Deeplink
On mobile, you can’t show a QR code (the user is already on their phone). Instead, generate the same MetaMask SDK URI and append it to MetaMask’s deeplink. This opens the MetaMask app directly, where the user approves the connection.Connect and verify
Get deeplinks from the wallet catalogue
Instead of hardcoding the deeplink URL, you can fetch it from the SDK’s wallet catalogue:Putting it all together
Here’s a complete example that detects the user’s environment and picks the right MetaMask connection flow automatically:Using the Wallet Options Catalogue
For a more automated approach,getWalletOptionsCatalogue merges all connection methods (extension, MetaMask SDK URI, WalletConnect, in-app browser) into a single ordered list per wallet. MetaMask’s entry will include a withWalletProvider option when the extension is installed, plus metamaskSdkUri options for QR/deeplink.
Related
- Build a Wallet Picker — the recommended pattern for rendering all wallets with automatic connection routing.
- Authenticate with WalletConnect — cross-device connections via WalletConnect (works with MetaMask and other wallets).
- Connecting and Verifying a Wallet — general wallet connection and verification reference.
- Authenticate with External Wallets — full external wallet authentication flow.
- Vite.js MetaMask QR code errors — troubleshooting CJS import errors in Vite dev server.