[{"_path":"/connectors/injected","_draft":false,"_partial":false,"_empty":false,"title":"Injected","description":"The InjectedConnector supports wallets that inject an Ethereum Provider into the browser or window. The MetaMask browser extension is the most popular example of this.","excerpt":{"type":"root","children":[{"type":"element","tag":"h2","props":{"id":"usage"},"children":[{"type":"text","value":"Usage"}]},{"type":"element","tag":"code","props":{"code":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector();\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector();\n"}]}]}]},{"type":"element","tag":"alert","props":{"type":"info"},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"💼 Injected wallets can set up custom name mappings in vagmi. You can "},{"type":"element","tag":"a","props":{"href":"https://github.com/tmm/wagmi/blob/main/packages/core/src/utils/getInjectedName.ts","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"see the\nfull list and add to it\nhere"}]},{"type":"text","value":".\nBy default, \"Injected\" is the name for unmapped wallets."}]}]},{"type":"element","tag":"h2","props":{"id":"configuration"},"children":[{"type":"text","value":"Configuration"}]},{"type":"element","tag":"h3","props":{"id":"chains-optional"},"children":[{"type":"text","value":"chains (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Chains supported by app. Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"defaultChains"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { chain } from 'vagmi';\nimport { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  chains: [chain.mainnet, chain.optimism],\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain } from 'vagmi';\nimport { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  chains: [chain.mainnet, chain.optimism],\n});\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"options-optional"},"children":[{"type":"text","value":"options (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Options for configuring the connector."}]},{"type":"element","tag":"code","props":{"code":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    shimDisconnect: true,\n  },\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    shimDisconnect: true,\n  },\n});\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"name"},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Name of connector instead of trying to detect from browser."}]},{"type":"element","tag":"code","props":{"code":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    name: 'Injected',\n  },\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    name: 'Injected',\n  },\n});\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" can also be set to a function, which has the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"detectedName"}]},{"type":"text","value":" as the first parameter. "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"detectedName"}]},{"type":"text","value":" can be a list of multiple detected names if there are multiple injected wallets detected."}]},{"type":"element","tag":"code","props":{"code":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    name: detectedName =>\n      `Injected (${\n        typeof detectedName === 'string'\n          ? detectedName\n          : detectedName.join(', ')\n      })`,\n  },\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    name: detectedName =>\n      `Injected (${\n        typeof detectedName === 'string'\n          ? detectedName\n          : detectedName.join(', ')\n      })`,\n  },\n});\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"shimchainchangeddisconnect"},"children":[{"type":"text","value":"shimChainChangedDisconnect"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Certain versions of MetaMask "},{"type":"element","tag":"a","props":{"href":"https://github.com/MetaMask/metamask-extension/issues/13375#issuecomment-1027663334","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"emit the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"\"disconnect\""}]},{"type":"text","value":" event when chain is changed"}]},{"type":"text","value":". This flag prevents the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"\"disconnect\""}]},{"type":"text","value":" event from being emitted upon switching chains. Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"false"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    shimChainChangedDisconnect: true,\n  },\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    shimChainChangedDisconnect: true,\n  },\n});\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"shimdisconnect"},"children":[{"type":"text","value":"shimDisconnect"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"MetaMask and other injected providers "},{"type":"element","tag":"a","props":{"href":"https://github.com/MetaMask/metamask-extension/issues/10353","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"do not support programmatic disconnect"}]},{"type":"text","value":". This flag simulates the disconnect behavior by keeping track of connection status in storage. Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"true"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    shimDisconnect: false,\n  },\n});\n","highlights":[5],"language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { InjectedConnector } from 'vagmi/connectors/injected';\n\nconst connector = new InjectedConnector({\n  options: {\n    shimDisconnect: false,\n  },\n});\n"}]}]}]}]},"_type":"markdown","_id":"content:4.connectors:1.injected.md","_source":"content","_file":"4.connectors/1.injected.md","_extension":"md"},{"_path":"/connectors/metamask","_draft":false,"_partial":false,"_empty":false,"title":"MetaMask","description":"The MetaMaskConnector supports connecting with MetaMask.","excerpt":{"type":"root","children":[{"type":"element","tag":"h2","props":{"id":"usage"},"children":[{"type":"text","value":"Usage"}]},{"type":"element","tag":"code","props":{"code":"import { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector();\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector();\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"configuration"},"children":[{"type":"text","value":"Configuration"}]},{"type":"element","tag":"h3","props":{"id":"chains-optional"},"children":[{"type":"text","value":"chains (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Chains supported by app. Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"defaultChains"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { chain } from 'vagmi';\nimport { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector({\n  chains: [chain.mainnet, chain.optimism],\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { chain } from 'vagmi';\nimport { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector({\n  chains: [chain.mainnet, chain.optimism],\n});\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"options-optional"},"children":[{"type":"text","value":"options (optional)"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Options for configuring the connector."}]},{"type":"element","tag":"code","props":{"code":"import { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector({\n  options: {\n    shimDisconnect: true,\n  },\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector({\n  options: {\n    shimDisconnect: true,\n  },\n});\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"shimchainchangeddisconnect"},"children":[{"type":"text","value":"shimChainChangedDisconnect"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Certain versions of MetaMask "},{"type":"element","tag":"a","props":{"href":"https://github.com/MetaMask/metamask-extension/issues/13375#issuecomment-1027663334","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"emit the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"\"disconnect\""}]},{"type":"text","value":" event when chain is changed"}]},{"type":"text","value":". This flag prevents the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"\"disconnect\""}]},{"type":"text","value":" event from being emitted upon switching chains. Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"true"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector({\n  options: {\n    shimChainChangedDisconnect: false,\n  },\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector({\n  options: {\n    shimChainChangedDisconnect: false,\n  },\n});\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"shimdisconnect"},"children":[{"type":"text","value":"shimDisconnect"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"MetaMask "},{"type":"element","tag":"a","props":{"href":"https://github.com/MetaMask/metamask-extension/issues/10353","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"does not support programmatic disconnect"}]},{"type":"text","value":". This flag simulates the disconnect behavior by keeping track of connection status in storage. Defaults to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"true"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector({\n  options: {\n    shimDisconnect: false,\n  },\n});\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { MetaMaskConnector } from 'vagmi/connectors/metaMask';\n\nconst connector = new MetaMaskConnector({\n  options: {\n    shimDisconnect: false,\n  },\n});\n"}]}]}]}]},"_type":"markdown","_id":"content:4.connectors:3.metamask.md","_source":"content","_file":"4.connectors/3.metamask.md","_extension":"md"}]