I am trying to write a React-next.js app. I have the following file that exports an instance of Web3 by passing in window.ethereum to the constructor.
import Web3 from 'web3'; const web3 = new Web3(window.ethereum); export default web3;
When next.js renders this on the server side, it throws the following error wherever I import this web3 on the browser.
ReferenceError: window is not defined
I have tried looking this up, but all the solutions suggest an if gate to check whether window is available or not inside functions that make use of window. But how to export web3 from this file?