Easy way to just "Connect Metamask wallet" in React

Just want to add a “Connect Wallet” button to an example app - so I can use the address from the user in the app - no need for store in cookies or any other extras :wink:
Just the most easiest way to get there with Moralis v2

This is the example app I am working with:
https://github.com/MoralisWeb3/Moralis-JS-SDK/tree/main/demos/react

Remark - searched the documentation already and this one is way to heavy for my use case:
https://docs.moralis.io/authentication-api/how-to-authenticate-users-with-metamask-using-react

Thanks a lot in advance …

I think that this is the easiest way to do it as you can see in this video, it only requires ethers library:

Thanks so much @cryptokid
It work nice and is simple

One more question related though:
Is there also a way to implement a button to “Disconnect” from the wallet again with ethers library?!

You cant disconnect the wallet programmatically because this feature is not built into the wallet. The users will have to manually disconnect it

How did then Moralis v1 offer a “logout” function !?

That function disconnects the user from the moralis database session, it doesn’t disconenct the wallet

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.