---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: noDocumentImportInPage
description: Learn more about noDocumentImportInPage
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="JSX and TSX" icon="seti:javascript">
## Summary
- Rule available since: `v1.9.4`
- Diagnostic Category: [`lint/suspicious/noDocumentImportInPage`](/reference/diagnostics#diagnostic-category)
- This rule is **recommended**, meaning it is enabled by default.
- This rule doesn't have a fix.
- The default severity of this rule is [**warning**](/reference/diagnostics#warning).
- This rule belongs to the following domains:
  - [`next`](/linter/domains#next)
- Sources: 
  - Same as [`@next/next/no-document-import-in-page`](https://nextjs.org/docs/messages/no-document-import-in-page)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"suspicious": {
				"noDocumentImportInPage": "error"
			}
		}
	}
}

```
## Description
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.

## Examples

### Valid

```jsx
import { Document, Html } from 'next/document'

export default class MyDocument extends Document {
  render() {
    return (
      <Html lang="en">
        {/* */}
      </Html>
    )
  }
}
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/lint/suspicious/no_document_import_in_page.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/tests/specs/suspicious/noDocumentImportInPage)

</TabItem>
</Tabs>