WalletConnect and Wagmi drops session on update

773 Views Asked by At

I try to add a "Connect Wallet" button to my dApp using WalletConnect's Web3Modal and Wagmi, but when I refresh the page the session is dropped and I need to login again. If I check any of the Web3Modal examples the wallet stays connected on refresh.

This is my code:

import { configureChains, createClient, connect } from '@wagmi/core'
import { mainnet, polygon } from '@wagmi/core/chains'
import { EthereumClient, modalConnectors, walletConnectProvider } from '@web3modal/ethereum'
import { Web3Modal } from '@web3modal/html'

const projectId = '*69c...426*'
const chains = [mainnet, polygon]

const { provider } = configureChains(chains, [walletConnectProvider({ projectId })])
const wagmiClient = createClient({
  autoConnect: true,
  connectors: modalConnectors({ appName: "web3Modal", chains: chains, version: "2", projectId: projectId }),
  provider
})
const ethereumClient = new EthereumClient(wagmiClient, chains)
const web3Modal = new Web3Modal({ projectId }, ethereumClient);

Do I miss something?

0

There are 0 best solutions below