Skip to content

noDocumentImportInPage

Diagnostic Category: lint/nursery/noDocumentImportInPage

Since: v1.9.4

Sources:

Prevents importing next/document outside of pages/_document.jsx in Next.js projects.

The next/document module is intended for customizing the document structure globally in Next.js. Importing it outside of pages/_document.js can cause unexpected behavior and break certain features of the framework.

import { Document, Html } from 'next/document'
export default class MyDocument extends Document {
render() {
return (
<Html lang="en">
{/* */}
</Html>
)
}
}