[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