Skip to content

Files

Latest commit

 

History

History
49 lines (36 loc) · 916 Bytes

no-script-component-in-head.md

File metadata and controls

49 lines (36 loc) · 916 Bytes

Pattern: Use of next/script inside next/head

Issue: -

Description

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" />
    </>
  )
}

Further Reading