2023-07-05 15:11:16 +02:00
|
|
|
---
|
|
|
|
title: 'No children were passed to `<Link>`'
|
|
|
|
---
|
2022-03-22 19:58:55 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Why This Error Occurred
|
2022-03-22 19:58:55 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
In your application code, `next/link` was used without passing a child:
|
2022-03-22 19:58:55 +01:00
|
|
|
|
|
|
|
For example:
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
```jsx filename="pages/index.js"
|
2022-03-22 19:58:55 +01:00
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
export default function Home() {
|
|
|
|
return (
|
2023-03-01 11:01:04 +01:00
|
|
|
<>
|
|
|
|
<Link href="/about" legacyBehavior></Link>
|
|
|
|
// or
|
|
|
|
<Link href="/about" legacyBehavior />
|
|
|
|
</>
|
2022-03-22 19:58:55 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Possible Ways to Fix It
|
2022-03-22 19:58:55 +01:00
|
|
|
|
|
|
|
Make sure one child is used when using `<Link>`:
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
```jsx filename="pages/index.js"
|
2022-03-22 19:58:55 +01:00
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
export default function Home() {
|
|
|
|
return (
|
2023-03-01 11:01:04 +01:00
|
|
|
<>
|
|
|
|
<Link href="/about">To About</Link>
|
|
|
|
// or
|
|
|
|
<Link href="/about" legacyBehavior>
|
|
|
|
<a>To About</a>
|
|
|
|
</Link>
|
|
|
|
</>
|
2022-03-22 19:58:55 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
```
|