vercel/next.js / errors / no-script-tags-in-head-component.mdx
The React Framework
no-script-tags-in-head-component.mdx
title: No Script Tags In Head Component
Why This Error Occurred
A <script> tag was added using the next/head component.
For the best performance, we recommend using next/script. Using next/script also ensures compatibility with React Suspense and streaming server-rendering.
Possible Ways to Fix It
Script Component
The Script component, next/script, allows you to optimally load third-party scripts anywhere in your Next.js application. It is an extension of the HTML <script> element and enables you to choose between multiple loading strategies to fit your use case.
import Script from 'next/script'
export default function Dashboard() {
return (
<>
<Script src="https://example.com/script.js" />
</>
)
}
Useful Links
Rendered from the public repository vercel/next.js on GitHub; content belongs to its authors. Cached for up to an hour.