rsnext/errors/no-document-title.mdx
Delba de Oliveira 44d1a1cb15
docs: Migrate error messages to MDX and App Router. (#52038)
This PR is part of a larger effort to migrate error messages to MDX and
use App Router: https://github.com/vercel/front/pull/23459
2023-07-05 06:11:16 -07:00

33 lines
723 B
Text

---
title: '`<title>` should not be used in _document.js `<Head>`'
---
## Why This Error Occurred
Adding `<title>` in `pages/_document.js` will lead to unexpected results with `next/head` since `_document.js` is only rendered on the initial pre-render.
## Possible Ways to Fix It
Set `<title>` in `pages/_app.js` instead:
```js filename="pages/_app.js"
import React from 'react'
import Head from 'next/head'
function MyApp({ Component, pageProps }) {
return (
<>
<Head>
<title>My new cool app</title>
</Head>
<Component {...pageProps} />
</>
)
}
export default MyApp
```
## Useful Links
- [The issue this was reported in: #4596](https://github.com/vercel/next.js/issues/4596)