44d1a1cb15
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
42 lines
909 B
Text
42 lines
909 B
Text
---
|
|
title: 'Multiple children were passed to `<Link>`'
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
In your application code multiple children were passed to `next/link` but only one child is supported:
|
|
|
|
For example:
|
|
|
|
```js filename="example.js"
|
|
import Link from 'next/link'
|
|
|
|
export default function Home() {
|
|
return (
|
|
<Link href="/about">
|
|
<a>To About</a>
|
|
<a>Second To About</a>
|
|
</Link>
|
|
)
|
|
}
|
|
```
|
|
|
|
## Possible Ways to Fix It
|
|
|
|
Make sure only one child is used when using `<Link>`:
|
|
|
|
```js filename="example.js"
|
|
import Link from 'next/link'
|
|
|
|
export default function Home() {
|
|
return (
|
|
<Link href="/about">
|
|
<a>To About</a>
|
|
</Link>
|
|
)
|
|
}
|
|
```
|
|
|
|
> **Good to know:**
|
|
>
|
|
> - As on Next.js 13.0, `<Link>` no longer requires a child `<a>` tag. A [codemod](/docs/app/building-your-application/upgrading/codemods#remove-a-tags-from-link-components) is provided to automatically update your codebase.
|