Files
vercel__next.js/errors/no-document-viewport-meta.mdx
Jam Balaya 7fe9065917 docs: typo file extension (#72272)
## Summary
Change [language and
filename](https://nextjs.org/docs/canary/community/contribution-guide#language-and-filename)
for match code block language.

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-11-04 23:16:21 +00:00

34 lines
804 B
Plaintext

---
title: 'Viewport `meta` tags should not be used in `_document.js` `<Head>`'
---
## Why This Error Occurred
Adding `<meta name="viewport" ...>` in `pages/_document.js` will lead to unexpected results since it cannot be deduped.
The viewport tag should be handled by `next/head` in `pages/_app.js`.
## Possible Ways to Fix It
Set your viewport `meta` tag in `pages/_app.js` instead:
```jsx filename="pages/_app.js"
import Head from 'next/head'
function MyApp({ Component, pageProps }) {
return (
<>
<Head>
<meta name="viewport" content="viewport-fit=cover" />
</Head>
<Component {...pageProps} />
</>
)
}
export default MyApp
```
## Useful Links
- [Issue #13230](https://github.com/vercel/next.js/issues/13230), which led to the creation of this warning.