<Script/> tag in Server Components
Unanswered
Brown bear posted this in #help-forum
Brown bearOP
Hello, I'm currently developing a website that uses MDX to render some of the pages.
In these pages I need to include an external script provided by another website. This script provides 1) a tooltip functionality 2) link manipulation (it finds specific links in the page, rewrites the text inside them and adds an icon)
If I add the <Script> tag in my layout then the feature #1 works fine, but the urls don't get rewritten until I refresh the page once (I assume then they stay like that as long as the page is cached?)
What is the correct approach here?
In these pages I need to include an external script provided by another website. This script provides 1) a tooltip functionality 2) link manipulation (it finds specific links in the page, rewrites the text inside them and adds an icon)
If I add the <Script> tag in my layout then the feature #1 works fine, but the urls don't get rewritten until I refresh the page once (I assume then they stay like that as long as the page is cached?)
onLoad doesn't work in server components, and using some sort of timeout or in general just force reloading the page seems wrong. What is the correct approach here?
1 Reply
Brown bearOP
I moved the <Script> element to a client component up in the chain. Seems to work. Let me know if this is somehow an anti-pattern