Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a vendor script into nextjs

Tags:

next.js

My app requires a script that isn't on npm so I have the file in my project folder, but how can I use it in my nextJs app?

I have tried putting the script in the public folder and then using next/head:

<Head>
  <script type="text/javascript" src="/public/CustomEase.min.js"></script>
</Head>

but the script cannot be found.

like image 519
Mark Steggles Avatar asked Dec 05 '25 14:12

Mark Steggles


1 Answers

Just use src="/CustomEase.min.js". The public folder is the root folder for your public URL.

like image 198
jdaz Avatar answered Dec 08 '25 15:12

jdaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!