-
Hey all, Solution (by @tmm ):Make sure that the creation of the client is done outside of the MyApp() component ProblemI am using the MetaMask connector and the connecting does work fine. When I change routes though (like from '/index' to 'index/coolpage') it seems like the connection between MetaMask and the site is lost. The status of useConnect is stuck in the reconnecting state. I don't know if I should just call the connect() function whenever it is in the reconnect state. It feels wrong though since it might lead to users getting the 'Connect to Metamask?' popup without explicitly prompting it, which would be bad UX. So I am hoping there is a way to somehow persist connection status between pages. I feel like this could have something to do with using the 'autoConnect' option in the client but I am not sure how that would effect that. Any help would be appreciated :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
What bundler/framework are you using (e.g. Next.js, Remix)? Some code to look at would be great too :) |
Beta Was this translation helpful? Give feedback.
-
Hi thanks for your reply! I am using Next.js.
This works perfectly well.
Do you see anything wrong with this? Could it be the way my routes are organised? Edit: _app.tsx
Solution (by @tmm ):Make sure that the creation of the client is done outside of the MyApp() component |
Beta Was this translation helpful? Give feedback.
Hi thanks for your reply!
I am using Next.js.
For the connection page I am pretty much using the code from the Next.js example from this repo.
I am only using the MetaMask connector for now.
In the first component where I initially connect the Wallet, the code looks something like this:
This works perfectly well.
The when I click in the NavBar of my App, the route changes from '/dashboard' to '/usecase/usecase1'.
This component w…