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] <appkit-button> does not reconnect on reload #3223

Open
webel opened this issue Nov 9, 2024 · 2 comments
Open

[bug] <appkit-button> does not reconnect on reload #3223

webel opened this issue Nov 9, 2024 · 2 comments
Labels
bug Something isn't working needs review

Comments

@webel
Copy link

webel commented Nov 9, 2024

Link to minimal reproducible example

https://github.com/webel/appkit-pure-html-example

Summary

This is the basic vanilla js example with wagmi as seen on https://docs.reown.com/appkit/javascript/core/installation.

Run MRE:

pnpm install
pnpm run dev 
// or simply: vite

Steps to reproduce:

  1. Connect wallet
  2. Reload page
  3. Observe that wallet is no longer connected

https://codesandbox.io/p/github/webel/appkit-pure-html-example

Tested with wallets: metamask, phantom and brave wallet.

List of related npm package versions

"@reown/appkit": "^1.3.1",
"@reown/appkit-adapter-wagmi": "^1.3.1",
"viem": "^2.21.44",
"wagmi": "^2.12.29"
@webel webel added bug Something isn't working needs review labels Nov 9, 2024
@webel webel changed the title [bug] <appkit-button> does not reconnect on reload (MRE available) [bug] <appkit-button> does not reconnect on reload Nov 9, 2024
@webel
Copy link
Author

webel commented Nov 9, 2024

Looking at e.g. the next implementation, a storage and initialState is loaded and passed on to the provider.

So, I guess, there should be an extra step to get the current state.

const updateConnectionState = async () => {
	// check if key exists in local storage @appkit/connected_connector
	// if it does, try wagmi reconnect
	const connectedConnector = localStorage.getItem('@appkit/connected_connector');

	if (connectedConnector) {
		loading.set(true);
		await reconnect(wagmiAdapter.wagmiConfig);
		loading.set(false);
	}
};

And then I use the loading state to switch between appkit-connect-button and appkit-account-button.

@ArmmGh
Copy link

ArmmGh commented Nov 19, 2024

I have the same issue after upgrading @reown/appkit-siwe and @reown/appkit from v1.3 to v1.4
I use next.js and I've thought the problem only there but it seems no. Each time I refresh the page SIWE asks to sign in.

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

No branches or pull requests

2 participants