Skip to content

nextjs/no-duplicate-head Correctness

This rule is turned on by default.

What it does

Prevent duplicate usage of <Head> in `pages/_document.js``.

Why is this bad?

This can cause unexpected behavior in your application.

Example

jsx
import Document, { Html, Head, Main, NextScript } from "next/document";
class MyDocument extends Document {
  static async getInitialProps(ctx) {}
  render() {
    return (
      <Html>
        <Head />
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}
export default MyDocument;

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny nextjs/no-duplicate-head --nextjs-plugin
json
{
  "plugins": ["nextjs"],
  "rules": {
    "nextjs/no-duplicate-head": "error"
  }
}

References

Released under the MIT License.