Connect to the MetaMask extension

Building a cross-platform or mobile dapp?

For cross-platform development, mobile integration, or advanced features like QR codes and deeplinking, connect to MetaMask using MetaMask SDK instead.

You can connect your dapp to users' MetaMask wallets by detecting MetaMask in their browsers and connecting to their accounts. This page provides instructions for connecting to MetaMask using the wallet detection mechanism introduced by EIP-6963. This approach allows you to detect multiple installed wallets and connect to them without conflicts.

You can connect to the MetaMask browser extension using third-party libraries or directly using Vite.

note

Using the Wallet API enables your dapp to work both with the MetaMask extension and in the in-app browser of the MetaMask mobile app. However, we recommend using the SDK for a more consistent mobile connection.

Connect to MetaMask using third-party libraries​

You can connect to MetaMask using the following third-party libraries that support EIP-6963:

Connect to MetaMask directly using Vite​

To connect to MetaMask directly, we recommend implementing support for EIP-6963 using the Vite build tool with vanilla TypeScript or React TypeScript.

Vanilla TypeScript​

Follow these steps for creating a vanilla TypeScript project to connect to MetaMask:

Made in Typedream