• React
  • Connectors
  • MetaMask

MetaMask

The MetaMaskConnector supports connecting with MetaMask.

import { MetaMaskConnector } from 'wagmi/connectors/metaMask'

Usage

import { MetaMaskConnector } from 'wagmi/connectors/metaMask'
 
const connector = new MetaMaskConnector()

Configuration

chains (optional)

Chains supported by app. Defaults to defaultChains.

import { mainnet, optimism } from 'wagmi/chains'
import { MetaMaskConnector } from 'wagmi/connectors/metaMask'
 
const connector = new MetaMaskConnector({
  chains: [mainnet, optimism],
})

options (optional)

Options for configuring the connector.

import { MetaMaskConnector } from 'wagmi/connectors/metaMask'
 
const connector = new MetaMaskConnector({
  options: {
    shimDisconnect: true,
  },
})

shimDisconnect

MetaMask does not support programmatic disconnect. This flag simulates the disconnect behavior by keeping track of connection status in storage. Defaults to true.

import { MetaMaskConnector } from 'wagmi/connectors/metaMask'
 
const connector = new MetaMaskConnector({
  options: {
    shimDisconnect: false,
  },
})

UNSTABLE_shimOnConnectSelectAccount

⚠️

This is an experimental feature. It's stable enough to show up in the docs, but should be used with care. If you have any feedback, create a discussion.

While "disconnected" with shimDisconnect, allows user to select a different MetaMask account (than the currently connected account) when trying to connect. Defaults to false.

import { MetaMaskConnector } from 'wagmi/connectors/metaMask'
 
const connector = new MetaMaskConnector({
  options: {
    shimDisconnect: true,
    UNSTABLE_shimOnConnectSelectAccount: true,
  },
})