Amin Jafarlou
Amin Jafarlou

Reputation: 511

Issue with Next/Script in NextJS 13 app router

I want to execute a script from the public directory. However, no matter how I pass the src to , it returns 404 error, indicating that the file does not exist, although the file exists in the public directory.

Here is a very simple example:

    const Home: NextPage = async () => {

     return (
      <>
       <Script src="/static/example.js" />

       <HomePage />
      </>
    );
   };

   export default Home;

Does anyone know how to handle this issue? I am using next version 13.5.3

Upvotes: 0

Views: 137

Answers (1)

Mohamed Bachar Touil
Mohamed Bachar Touil

Reputation: 26

try to wrap the Script component with Head component from "next/document"

Upvotes: 0

Related Questions