Re-using Web3Auth Provider without Login Modal

  • SDK Version(package.json):“^7.3.2”
  • Platform: Web(Desktop)
    this is the piece of code i am using
const web3auth = new Web3Auth({
  clientId: WEB_3_AUTH_CLIENT_ID,
  chainConfig: {
    chainId: numberToHex(CHAIN_ID),
    chainNamespace: "eip155",
    rpcTarget: "https://rpc-amoy.polygon.technology",
  },
  uiConfig: {
    dark: true,
  },
  web3AuthNetwork: web3AuthNetwork[CHAIN_ID],
});

await web3auth.initModal({
  modalConfig: {
    [WALLET_ADAPTERS.OPENLOGIN]: allowedSocialMethods,
  },
});

await web3auth.connect();
provider = web3auth.provider;

Before, the code used to directly access the provider object if a user was already logged in, skipping the login modal. Now, it’s consistently prompting the login modal regardless of the user’s login status.

My goal is to avoid this repetition and obtain the provider object on subsequent pages without showing the login modal for already logged-in users.
How do i achieve this?
(PS:I can’t store web3auth instance in frontend cause it is sensitive information)

hi @tarun

I hope you are doing well ?

Did you check our EVM PnP SDK example ?
I’m sure this example will help you to achieve what you are planning to do.

Don’t hesitate to get in touch with me if you continue with the issue.