rsnext/errors/invalid-new-link-with-extra-anchor.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

23 lines
653 B
Text

---
title: 'Invalid `<Link>` with `<a>` child'
---
## Why This Error Occurred
Starting with Next.js 13, `<Link>` renders as `<a>`, so attempting to use `<a>` as a child is invalid.
## Possible Ways to Fix It
Run the `new-link` codemod to automatically upgrade previous versions of Next.js to the new `<Link>` usage:
```bash filename="Terminal"
npx @next/codemod new-link .
```
This will change `<Link><a id="link">Home</a></Link>` to `<Link id="link">Home</Link>`.
Alternatively, you can add the `legacyBehavior` prop `<Link legacyBehavior><a id="link">Home</a></Link>`.
## Useful Links
- [next/link](/docs/pages/api-reference/components/link)