Persisting web3auth provider through refrsh

  • SDK Version: 6.1.3
  • Platform: Chrome Browser

After refreshing the page, I’m losing the Web3Auth provider. How can I retain the Web3Auth provider without requiring the user to log in again?

this is the custom function i am using :

import Web3 from “web3”;
import { allowedSocialMethods, numberToHex } from “…/Components/Auth/helpers”;
import { CHAIN_ID, WEB_3_AUTH_CLIENT_ID } from “…/config”;
import { Web3Auth } from “@web3auth/modal”;
import { WALLET_ADAPTERS } from “@web3auth/base”;

let web3Instance;
let web3auth;
let userInfo;
const getWeb3AuthInstance = async () => {
if (!web3Instance) {
web3auth = new Web3Auth({
chainConfig: {
chainId: numberToHex(CHAIN_ID),
chainNamespace: “eip155”,
uiConfig: {
dark: true,
await web3auth.initModal({
modalConfig: {
[WALLET_ADAPTERS.OPENLOGIN]: allowedSocialMethods,
await web3auth.connect();

web3Instance = new Web3(web3auth.provider);

userInfo = await web3auth.getUserInfo();

return { web3auth, web3Instance, userInfo };

export { getWeb3AuthInstance };


@tarun Thanks for your question.

Your request has been forwarded to a team and we will get back with further updates once more information becomes available

@tarun This might be happening because your code is not looking for already logged in sessions. Have a look at our examples. I’ll attach a link here for your convenience. Let me know if this helps you.

Even I am facing the same issue
In the offcial example repo code

  const login = async () => {
    if (!web3auth) {
      uiConsole("web3auth not initialized yet");
    const web3authProvider = await web3auth.connect();

I am losing the web3auth instance on refresh and then it is again showing modal asking for login.

hey @puneet please me know the version of the SDK you are using

I am also using SDK Version: 6.1.3

1 Like

Hey @puneet, do you have the useEffect in place in your code? I am asking this because the official example repo code works fine on my local.

Do you still face this issue? I would be glad to assist you more on this if required.