check web3 metamask disconnect
// The following code snippet is in React // but you can use the window.ethereum.on("accountsChanged") event // in regular JavaScript // Note: I believe window.ethereum is only available if using Metamask // as your web3 provider useEffect(() => { window.ethereum.on("accountsChanged", accounts => { if (accounts.length > 0) setAccount(accounts[0]); else setAccount(""); }); }, []);