Next.js: Error: React.Children.only expected to receive a single React element child

This issue is due to the space between <Link> tag and <a> tag.

So change your code like,

        <div>
            <Link href="https://stackoverflow.com/"><a> Home </a></Link>
            <Link href="http://stackoverflow.com/about"><a> About </a></Link>
        </div>

Reason for the change:

-> The <Link> can have only one child node and here the space between the link and a tag are considered as a child nodes.

-> So there are two child nodes (One is space and another is <a> tag) which is invalid and hence such error occurs.

Leave a Comment