I'm getting this error: Do not add <script> tags using next/head (see inline <script>).
Unanswered
Polar bear posted this in #help-forum
Polar bearOP
I'm getting this error in the browser console:
Even though I'm not adding a script, I'm just doing this:
Any idea why I'm getting this error? @Plott Hound
Do not add <script> tags using next/head (see inline <script>). Use next/script instead.
See more info here: https://nextjs.org/docs/messages/no-script-tags-in-head-componentEven though I'm not adding a script, I'm just doing this:
export const getServerSideProps = (async (/* context */) => {
// ...
return { props }
}) satisfies GetServerSideProps<MyPageProps>
export default function Page(props: MyPageProps) {
return (
<>
<Head>
<title>My Page Title</title>
</Head>
<RenderMyPage {...props} />
</>
)
}Any idea why I'm getting this error? @Plott Hound
31 Replies
somewhere you are using <script> instead of <Script>
@Plott Hound https://nextjs.org/docs/app/building-your-application/optimizing/scripts
Polar bearOP
I don't understand why the error is even mentioning scripts
@Plott Hound somewhere you are using <script> instead of <Script>
Polar bearOP
I'm not :)
I'm not even using
<Script>Plott Hound
sounds like its coming from an npm lib or something then.
Polar bearOP
I'm using Image from next/image. Could that be it?
Plott Hound
also sorry i gave you the app router link instead of the pages router link:
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts
@Plott Hound also sorry i gave you the app router link instead of the pages router link:
https://nextjs.org/docs/pages/building-your-application/optimizing/scripts
Polar bearOP
what's the difference between both routers?
Plott Hound
App router was introduced in NExt 13 and is the new way of doing things. Pages is still supported but App router is encouraged
this is not why you're getting an error btw.
@Plott Hound sounds like its coming from an npm lib or something then.
Polar bearOP
My project is based on this template. I didn't change much. https://github.com/timothymiller/t4-app/blob/4803ec782e9f61ea7459df3dc60a7b7ab902c363/apps/next/pages/index.tsx#L7
Plott Hound
search your codebase for "script" and let me know what the results are
Polar bearOP
E.g. I'm getting the same error when not using
getServerSideProps / Image@Plott Hound search your codebase for "script" and let me know what the results are
Polar bearOP
if I search for
<script, zero resultsPlott Hound
yeah the error is coming from somewhere else. possibly in the RenderMyPage component or in another component that's being used within RenderMyPage.
what libs have you installed other than next?
@Plott Hound what libs have you installed other than next?
Polar bearOP
only the ones that this template uses:
https://github.com/timothymiller/t4-app/blob/4803ec782e9f61ea7459df3dc60a7b7ab902c363/apps/next/pages/index.tsx#L7
https://github.com/timothymiller/t4-app/blob/4803ec782e9f61ea7459df3dc60a7b7ab902c363/apps/next/pages/index.tsx#L7
Plott Hound
ok lemme check the github 1 sec
Polar bearOP
thanks :)
@Polar bear thanks :)
Plott Hound
did you install it with bun?
@Plott Hound did you install it with bun?
Polar bearOP
yes
this template only works with bun
Plott Hound
just installing it to see if it works for me
@Plott Hound just installing it to see if it works for me
Polar bearOP
I really appreciate you helping me :)
I'm using the
I'm using the
lucia branch btw@Polar bear I really appreciate you helping me :)
I'm using the `lucia` branch btw
Plott Hound
this is gonna take me a while to get setup so i'll have to finish it when i get back from work sorry
Polar bearOP
yeah no worries :)
Plott Hound
im so confused why they are using pages router for this :/
ok i'll have a deeper look tonight and get back to you
i can confirm there are no <script> tags in the codebase so idk what would cause that error