1

I want to add a preloader in my nextjs app.

my _app.js file

// a loading file inside components folder
import Loader from '../components/loader'

    function MyApp({ Component, pageProps }) {
    return <>
        <Component {...pageProps} />
           </>
    }

export default MyApp

how can I add a loader when the page load at the first time in next js because there is no window property so i can't use window.onload

please tell me if any solution is there

  • check this please: https://stackoverflow.com/questions/55624695/loading-screen-on-next-js-page-transition – Mahmood A.Shakir May 08 '22 at 13:35
  • Keep in mind that if you add a loader at the `_app` level to prevent rendering until `window` is defined, you're forcing all pages to fully render on the client-side, defeating the purpose of using Next.js for its SSR benefits. – juliomalves May 08 '22 at 17:29

0 Answers0