Next.js Discord

Discord Forum

Failed script

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
When I add the script, I get an error like this, how can I fix it?
app-index.js:32 Warning: Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async="" or moving it into the root <head> tag.

app-index.js:32 Warning: validateDOMNesting(...): <script> cannot appear as a child of <html>.


import Script from "next/script";

export const metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body className={[inter.className, 'bg-surface-0 dark:bg-surface-950 ']} style={inter.style}>
        <Layout>
          {children}
        </Layout>
      </body>
      <Script src="/scripts/prism/prism.js" strategy="beforeInteractive" async/>
    </html>
  );
}

0 Replies