Next.js Discord

Discord Forum

I'm getting this error: Do not add <script> tags using next/head (see inline <script>).

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I'm getting this error in the browser console:
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-component

Even 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
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
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 results
Plott 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
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 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