silverwolf-x/project / errors /no-script-component-in-head.mdx
silverwolf-x's picture
download
raw
942 Bytes
---
title: No Script Component in Head
---
> Prevent usage of `next/script` in `next/head` component.
## Why This Error Occurred
The `next/script` component should not be used in a `next/head` component.
## Possible Ways to Fix It
Move the `<Script />` component outside of `<Head>` instead.
**Before**
```jsx filename="pages/index.js"
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**
```jsx filename="pages/index.js"
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
- [next/head](/docs/pages/api-reference/components/head)
- [next/script](/docs/pages/guides/scripts)

Xet Storage Details

Size:
942 Bytes
·
Xet hash:
eddd0d83ec680fed973f431038926ce627e2175090e1c1fee83987d8cd659125

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.