Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 869 Bytes

no-script-component-in-head-component.md

File metadata and controls

48 lines (36 loc) · 869 Bytes

Script component inside Head component

Why This Error Occurred

The next/script component shouldn't be placed inside the next/head component

Possible Ways to Fix It

Move the <Script /> component outside of <Head>...</Head>

Before

import Script from 'next/script'
import Head from 'next/head'

export default function Index() {
  return (
    <Head>
      <title>Next.js</title>
      <Script src="/my-script.js" />
    </Head>
  )
}

After

import Script from 'next/script'
import Head from 'next/head'

export default function Index() {
  return (
    <>
      <Head>
        <title>Next.js</title>
      </Head>
      <Script src="/my-script.js" />
    </>
  )
}

Useful links