Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] isConnected always returning false, when clearly connected #446

Open
patrick-streaming opened this issue Feb 4, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@patrick-streaming
Copy link

Describe the bug

I have the following code:

'use client'

import { useEffect, useState } from 'react'
import { useAccount } from 'wagmi'

export default function Home() {
  const { isConnected, address, status } = useAccount()

  useEffect(() => {
    console.log(isConnected)
    console.log(address)
    console.log(status)
  }, [isConnected, address, status])

And on my UI, Metamask is clearly connected (my metamask, show it's connected to the site, and you can see the address of my metamask being console.logged out):

Image

Whenever I refresh the page, it just keeps saying not connected

To reproduce

  1. Use the import { useAccount } from 'wagmi' hook, and in a component, add:
export default function Home() {
  const { isConnected, address, status } = useAccount()

  useEffect(() => {
    console.log(isConnected)
    console.log(address)
    console.log(status)
  }, [isConnected, address, status])
  1. Connect your metamask with a connect button
  2. Refresh the page, it'll always have isConnected be false

Optionally, you can see this repo for more information.

Expected behavior

isConnected should be true, as my Metamask says it's true

Screenshots

See above

Environment details

nodejs: v23.5.0
"wagmi": "^2.14.9"
"connectkit": "^1.8.2",

Tagging @PatrickAlphaC

@patrick-streaming patrick-streaming added the bug Something isn't working label Feb 4, 2025
@patrick-streaming
Copy link
Author

Doubled checked with rainbowkit, it looks like the same codebase connected to a rainbowkit wallet, returns the correct connected status.

Image

@PatrickAlphaC
Copy link

PatrickAlphaC commented Feb 7, 2025

After trying to reproduce this error, I'm unable to.

I'll close for now.

(Whoops, I'm on my wrong account, I'll have to switch)

@MOZGIII
Copy link

MOZGIII commented Feb 8, 2025

We see the same in our tests. Looks like connectkit does not initialize the state properly, i.e. assumes wagmi can't be connected at initialization, or sth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants