MetaMask

The MetaMaskConnector supports connecting with MetaMask.


Usage

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

Configuration

chains (optional)

Chains supported by app. Defaults to defaultChains.

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

options (optional)

Options for configuring the connector.

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

shimChainChangedDisconnect

Certain versions of MetaMask emit the "disconnect" event when chain is changed. This flag prevents the "disconnect" event from being emitted upon switching chains. Defaults to true.

import { MetaMaskConnector } from 'vagmi/connectors/metaMask';const connector = new MetaMaskConnector({  options: {    shimChainChangedDisconnect: false,  },});

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 'vagmi/connectors/metaMask';const connector = new MetaMaskConnector({  options: {    shimDisconnect: false,  },});