I am looking for a way to connect metamask wallet to my react application using mobile (android and ios both), already integrated the wallet connection via chrome extension for desktop as follow

const initializeWeb3 = async () => {
    try {
      localStorage.setItem("meta-account", false);
      if (
        typeof window !== "undefined" &&
        typeof window.ethereum !== "undefined"
      ) {
        const accounts = await window.ethereum.request({
          method: "eth_requestAccounts",
        web3js = new Web3(window.ethereum);
      else {
        toast.error("Please install metamask!");
        ethereum.request({ method: 'eth_requestAccounts', params: [] });

      window.ethereum.on("chainChanged", function (networkId) {
      window.ethereum.on("accountsChanged", (account) => {
        account = account;
    } catch (error) {
      if (error.code == -32002) {
        toast.error("Metamask already opened!");
      else {

can anyone help me integrate the mobile connection as well

1 Answer 1


Turns out all I had to do was to include the metamask SDK in my reactJs application

import MetaMaskSDK from "@metamask/sdk";

and then create its instance, rest of the code remains the same

new MetaMaskSDK({
   useDeeplink: false,
   communicationLayerPreference: "socket",

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.