Skip to content
Advertisement

Error: Invalid with child after updating to Next.js 13

After updating Next.js to version 13, I got this client error

enter image description here

<Link href="/contact">
  <a>
    Contact
  </a>
</Link>

Advertisement

Answer

To fix this error, remove the a tag from the link. From the link in the error message:

Starting with Next.js 13, <Link> renders as <a>, so attempting to use <a> as a child is invalid.

Invalid

<Link href="/contact">
  <a>
    Contact
  </a>
</Link>

Valid

<Link href="/contact">
    Contact
</Link>
Advertisement