Skip to content

Files

Latest commit

 

History

History
38 lines (30 loc) · 677 Bytes

no-script-component-in-head.md

File metadata and controls

38 lines (30 loc) · 677 Bytes

Pattern: Script component in Head

Issue: -

Description

The next/script component should not be placed within next/head. Scripts should be placed directly in the body of the document to ensure proper loading and execution.

Examples

Example of incorrect code:

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

export default function Page() {
  return (
    <Head>
      <Script src="/analytics.js" />
    </Head>
  )
}

Example of correct code:

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

export default function Page() {
  return (
    <>
      <Head />
      <Script src="/analytics.js" />
    </>
  )
}