Displaying loading screen until static Next.js app is rendered

I want to display a loading screen before the whole static page is loaded. I am using modules:export to create the static page. But I can not listen to the window load event as when NextJs executes, the window has already been loaded.

I tried using an external script using next/script, but I can’t get my head around how to listen to it from inside the next app.

If anyone has any idea on how to achieve this, please help me. Thank you.