Im trying to prompt user before leaving page. I Noticed when user enters page from a element link then when I click back, beforeunload event fires.
However, when user enters page through NextJs Link component then clicking back wont fire beforeunload event.
How can I still prompt user when using component?
for example going tho page through this Link and clicking back wont trigger beforeunload
<Link href={`/event/${encodeURIComponent(event.slug)}`}>
<a>
<h3>{event.name}</h3>
</a>
</Link>
but regular a element linking will then afterwards fire beforeunload when clicking back
example
<a href={"event/" + event.slug}>
<h3>{event.name}</h3>
</a>