title: How to load theme javascript files in nextjs
body: <p>I am going to use a theme of themeforest on Next.js</p>
  <p>I tried to load jquery core and some plugins, but Nextjs can't load it.</p>
  <pre><code>import { useEffect } from &quot;react&quot;
  import { SessionProvider } from &quot;next-auth/react&quot;
  import Script from 'next/script'
  
  import '../public/plugin/datatables/responsive.dataTables.min.css'
  import '../public/plugin/datatables/dataTables.bootstrap5.min.css'
  
  import '../public/css/cryptoon.style.min.css'
  // import &quot;./styles.css&quot;
  
  export default function App({ Component, pageProps }) {
    return (
      
      &lt;div&gt;
      &lt;SessionProvider session={pageProps.session}&gt;
        &lt;Component {...pageProps} /&gt;
      &lt;/SessionProvider&gt;
      
      &lt;Script type=&quot;text/javascript&quot; src=&quot;/bundles/libscripts.bundle.js&quot; strategy=&quot;lazyOnload&quot; /&gt;
      &lt;Script type=&quot;text/javascript&quot; src=&quot;/bundles/apexcharts.bundle.js&quot; strategy=&quot;lazyOnload&quot; /&gt;
      &lt;Script type=&quot;text/javascript&quot; src=&quot;/js/template.js&quot; strategy=&quot;lazyOnload&quot; /&gt;
      &lt;Script type=&quot;text/javascript&quot; src=&quot;/js/page/index.js&quot; strategy=&quot;lazyOnload&quot; /&gt; 
      &lt;/div&gt;
    )
  }
  </code></pre>
  <p>But a bunch of errors have occurred:</p>
  <pre><code>Unhandled Runtime Error
  TypeError: Cannot read properties of null (reading 'addEventListener')
  
  Call Stack
  HTMLDocument.&lt;anonymous&gt;
  /js/template.js (185:18)
  e
  /bundles/libscripts.bundle.js (1:29754)
  t
  /bundles/libscripts.bundle.js (1:30078)
  </code></pre>
  <p>....</p>
  <p>How to load template(HTML/CSS/JAVASCRIPT) to Nextjs component?</p>