I'm trying to access the ethers provider like this in Nextjs 13.0.1:
import { ethers } from "ethers";
export const signMessage = () => {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
try {
signer.signMessage("Hey hey").then((result) => {
console.log(result);
});
} catch (error) {
// handle error
console.log(error);
}
};
But it always gives me the error:
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'Web3Provider')
I've tried different providers but always get the error message above.
Someone knows why it's working for Nextjs 12 but not for Next 13?