How to host my dapp on moralis without index.html?

Hello so i dont use index.html but only index.js and i want to host my dapp on moralis. I followed this tutorial : https://www.youtube.com/watch?v=RiH0ADGPleg&t=192s but when i type moralis-admin-cli deploy it need an index.html but i only use index.js. I use npm run dev to run it locally. I basically used this tutorial to build my dapp Build a Mini Buymeacoffee dApp Using Solidity + Ethereum Smart Contract + ReactJs + TailwindCSS (idrisolubisi.com)

you need an index.html, Moralis only has static hosting now, react will also generate an index.html on build

1 Like

Ok thank you, any recommendation on where should i host my dapp?

You have to create a build with npm run build or whatever build command your project is using, this is what you deploy.

You can use Netlify or Vercel if you don’t want to host on Moralis.

i tried to deploy it with build command but there is no functions and css styles

Where did you try to deploy it? Best thing to do is to build your project and run it locally first with a webserver.

i tried on netflify, vercel and moralis but when i run npm run build i dont see the build folder but it creates inside .next folder and in there under the folder pages i can find index.html but its different from index.js like without css and functions. i run npm run dev to deploy my project locally without any issues

what exactly you see in that folder where is index.html, what other files?

Did you follow deploy instructions for Netlify or Vercel?

Don’t think you will be able to use Moralis for Next.js.

yes every time i get 404 page error

After you build, you need to export in Nextjs to get an out folder by running npm run export. The out folder should have index.html file which you can deploy then

Do you get any errors when you deploy (not just the 404)? Check the deploy logs. Are you able to share a generic repo of your site if you still have problems? I can deploy any regular Next.js site with Vercel for example if I connect a repo to it.

coffee/my-app at main · Dulogg/coffee (github.com)
And my deploy logs :

That repo you linked is not public. How have you imported the .json and .png?

Dulogg/testmorals (github.com) this should be public and i dont have deploy logs anymore because i added export to run build script. If you will able to deploy it could you tell me how? Thank you so much for helping me btw.

Hi I’ve found the issue; you need to move the CoffeePortal.json or utils folder into your my-app. It can’t find the import because it’s outside the app/project directory. This works locally because the rest of your filesystem is available but when deploying, Vercel would only have access to this my-app directory.

And then for example change
import abi from "./../../utils/CoffeePortal.json";

to

import abi from "../utils/CoffeePortal.json";

Same for the other one.

Also you are not using img1/QRcode so you can comment this out anyway.

This is working with the regular next build command.

1 Like

Oh thanks, works for me now. Thanks a lot for helpIng me.