[SOLVED] NextJS Error: Web3Api not initialized, run Moralis.start() first

Hi,

I’m trying to use “getTokenMetadata” function using Web3 API, but having initialization error,
I checked other topics about it, but can’t solve the issue,
I’ve used this documentation to setup SDK: https://docs.moralis.io/moralis-dapp/connect-the-sdk/connect-with-react

Please check all screenshots, there are all necessary codes

Can you please provide exact code that I need to implement in order to start Moralis?
I covered [1,2,3] steps, but I don’t want to cover step 4, because I don’t want user to submit popup to login on website, please also describe if [4,5,6,7] steps are required in order to use “getTokenMetadata” function from Web3 API

Thanks in advance

You can use isInitialized from the useMoralis hook to only run Moralis functions once it is ready.

const { isInitialized } = useMoralis();

...

useEffect(() => {
  if (isInitialized) {
    fetchData();
  }
}, [isInitialized]);
2 Likes

Working :slight_smile: thanks a lot