Next.js Discord

Discord Forum

Warning: Expected server HTML to contain a matching <a> in <div>.

Unanswered
ᵗʰᵉ Nexus posted this in #help-forum
Open in Discord
How to fix this error?

(Link Error)

6 Replies

this component looks fine, I am pretty sure p is a valid child of the a tag. maybe try to replace it with a span just to make sure? besides that, the issue could be in the component that is rendering this Item component
ja, I would try to avoid p as much as possible
My guess is that the component we are looking at is mounted as a child of another link
Something like that. Can you look at the error above the one you posted? I found that that error usually states why the server excluded certain tags
I think it's likely you are using an outdated version of Next.js, since I don't get this error in Next.js 13.5.2
It worked perfectly
<Link href="/" prefetch={false}>
  <p>Hello World</p>
  <Image alt="banner" width={100} height={100} src="/banner.png" />
</Link>