Next.js 13+: Error: Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>
Since Next.js 13 <Link> renders its own <a>, so nesting your own <a> is invalid.
Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>Invalid <Link> with <a> childError: Invalid <Link> with <a> child. Please remove <a>Multiple children were passed to <Link> with `href`nested anchor <a> inside <Link> Next.js Meaning
Remove the inner anchor and put classes/attributes on <Link> itself: <Link href="/x" className="btn">Text</Link>. A codemod exists: npx @next/codemod new-link .. Use legacyBehavior only for libraries needing a child element.
Common causes
- Old code
<Link href><a>text</a></Link> - Component libraries wrapping Link with an anchor child
- Copy from Next 12 tutorials
- Custom button components using
<a> - Styling attached to the inner
<a>
⚡ Quick fix
<Link href="/about" className="nav">About</Link>- Run
npx @next/codemod new-link . legacyBehavioronly if unavoidable
Detailed fix by platform
Next.js
npx @next/codemod@latest new-link .
How to diagnose
- Markup — Nested <a>?
- Styles — Move to Link?
- Lib — Needs legacyBehavior?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Conflicting app and page file was found Next.js: ⨯ Conflicting app and page file was found, please remove the conflicting files to continue: "pages/index.tsx" - "app/page.tsx"
- CORS error calling Next.js API route / route handler Browser: Access to fetch at 'https://api.example.com/api/data' from origin 'https://app.example.com' has been blocked by CORS policy (Next.js route handler)
- Failed prop type: The prop href expects a string or object in <Link> Next.js: Error: Failed prop type: The prop `href` expects a `string` or `object` in `<Link>`, but got `undefined` instead
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026