1

I would like to implement a script within my next.js app I'm currently using

import Script from "next/script";

and then within my

return (
<div>
<Script>const tooltips= {color: true, icon: true, size: true}</Script>
<Script src="url to script"></Script>
<main>
</main>
</div>
)

the script loads, but how can i set the tooltips const in nextjs? using

const something = ""

doesn't work. I tried using the script within a normal html file and it works. How would i implement this in nextjs? I'm probably already implementing it wrong because i cant use const after my return? What would be the right way to set these values?

jdevnew
  • 21
  • 4
  • you can use `globalThis.tooltips`. Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis – Sumit Surana Sep 09 '21 at 08:08
  • Does this answer your question: [How to add – juliomalves Sep 09 '21 at 20:23

0 Answers0