//metamask enject ethereum object in browser so you can easily connect.
//this is pure js way you can use ethers.js and web3.js in react.Thanks
let accounts;
const enableEth= async()=> {
accounts= await window.ethereum.request({method:'eth_requestAccounts'})
.catch((err)=> {
//error handling
console.log(err.code) //errorcode 4001 user reject request
})
console.log(accounts); //["your connected wallet"]
}
async function connectWallet() {
const provider = new ethers.providers.Web3Provider(window.ethereum)
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner()
}