[Next.js] Override the Default Next.js Document

The Document is like the top level HTML structure of your Next.js application. You can use document to change the default language, set favicon;

Because Document only render on Server side, so it doesn't support event such as onClick....

pages/_document.txs

import { Html, Head, Main, NextScript } from "next/document";

export default function Document() {
  return (
    <Html lang="en">
      <Head>
          <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22" />
      </Head>
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  )
}

 

posted @ 2022-05-24 17:21  Zhentiw  阅读(37)  评论(0编辑  收藏  举报