Skip to content

Inline script id

Source URL: https://nextjs.org/docs/messages/inline-script-id

Enforce id attribute on next/script components with inline content.

next/script components with inline content require an id attribute to be defined to track and optimize the script.

Add an id attribute to the next/script component.

import Script from 'next/script'
export default function App({ Component, pageProps }) {
return (
<>
<Script id="my-script">{`console.log('Hello world!');`}</Script>
<Component {...pageProps} />
</>
)
}