I find myself in a scenario where I must dynamically inject CSS into a webpage.
The content of this page is constantly changing, and I am provided with raw HTML and a link to a CSS file from a server that needs to be displayed on the page.
My attempt to add it to a <Head>
tag in next.js was successful, but it resulted in a warning:
Avoid adding stylesheets using next/head (consider using <link rel="stylesheet"> tag with href="my-url"). Utilize Document instead.
This directive stems from this page. Unfortunately, since that page is exclusively for SSR, I am unable to dynamically set the CSS there (e.g., using React context).
Is there a way to accomplish this task without triggering any warnings? Thank you.