Files
vercel__next.js/errors/link-no-children.mdx
Hendrik Liebau 4b66771895 Remove deprecated legacyBehavior and passHref prop from Link component (#83003)
The `legacyBehavior` prop of the `Link` component has been deprecated
since #77473. For Next.js 16, we're finally removing support for it.
Consequently, we're also removing support for the `passHref` prop, which
was only useful in conjunction with the `legacyBehavior` prop.

A [codemod is
available](https://nextjs.org/docs/app/guides/upgrading/codemods#new-link)
to help you automatically upgrade your codebase.

reverts #77473

---------

Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
2025-08-26 14:04:27 +02:00

46 lines
988 B
Plaintext

---
title: 'No children were passed to `<Link>`'
---
> **Note**: Starting with version `16`, Next.js does not support the `legacyBehavior` prop for a `Link` component anymore . `<Link>` now renders an `<a>` element automatically, and does not restrict the number of children passed to it.
## Why This Error Occurred
In your application code, `next/link` was used without passing a child:
For example:
```jsx filename="pages/index.js"
import Link from 'next/link'
export default function Home() {
return (
<>
<Link href="/about" legacyBehavior></Link>
// or
<Link href="/about" legacyBehavior />
</>
)
}
```
## Possible Ways to Fix It
Make sure one child is used when using `<Link>`:
```jsx filename="pages/index.js"
import Link from 'next/link'
export default function Home() {
return (
<>
<Link href="/about">To About</Link>
// or
<Link href="/about" legacyBehavior>
<a>To About</a>
</Link>
</>
)
}
```