Next.js Loads tags but it doesn’t execute them

This works to me:

Create a folder for your static files:

<root>/public/static/script.js

in your index.js at <root>/pages/index.js

import Head from 'next/head';
import MyAwesomeComponent from '../components/mycomponent';

export default () => (
  <div>
    <Head>
      <script type="text/javascript" src="/static/script.js"></script>
    </Head>
    <MyAwesomeComponent />
  </div>
)

Note that static is the name I used in this example, it’s not a requirement, it would work with any other folder name.

Leave a Comment

tech