vercel/next.js · error · Error
`<Link legacyBehavior>` received a direct child that is eith
Error message
`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag.
What it means
Error "`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag." thrown in vercel/next.js.
Source
Thrown at packages/next/src/client/app-dir/link.tsx:555
if (href) {
const hasDynamicSegment = href
.split('/')
.some((segment) => segment.startsWith('[') && segment.endsWith(']'))
if (hasDynamicSegment) {
throw new Error(
`Dynamic href \`${href}\` found in <Link> while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href`
)
}
}
}
}
// This will return the first child, if multiple are provided it will throw an error
let child: any
if (legacyBehavior) {
if ((children as any)?.$$typeof === Symbol.for('react.lazy')) {
throw new Error(
`\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.`
)
}
if (process.env.NODE_ENV === 'development') {
if (onClick) {
console.warn(
`"onClick" was passed to <Link> with \`href\` of \`${formattedHref}\` but "legacyBehavior" was set. The legacy behavior requires onClick be set on the child of next/link`
)
}
if (onMouseEnterProp) {
console.warn(
`"onMouseEnter" was passed to <Link> with \`href\` of \`${formattedHref}\` but "legacyBehavior" was set. The legacy behavior requires onMouseEnter be set on the child of next/link`
)
}
try {
child = React.Children.only(children)
} catch (err) {View on GitHub (pinned to 0eb3775416)
Solutions
- Remove legacyBehavior, or make the direct child a Client Component rendering the <a> tag.
Defensive patterns
Strategy: validation
When it happens
Trigger: <Link legacyBehavior> wraps a Server Component or React.lazy child.
Common situations: A legacyBehavior Link whose direct child is a Server Component or lazily loaded JSX.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/f51936f2463d581a.
Report an issue: GitHub.