Hope all are doing good. I will directly move to the issue, I am trying to migrate my React-Typescript to Next JS for routing purpose. I am using Link -next/link but it is not working when the server is started but after a refresh routing is working fine. I am missing somewhere, could you please help me out?
<div>
<Link href='/page1' as={`/page1`}>
<a>Page1</a>
</Link>
<p>Welcome to the page 2</p>
</div>
After so many research I couldn't find anything in the interim, I randomly tried something, now the code is working as expected but I want to know how it is working. Below I have pasted the working code
<div>
<Link href='/' as={`/page1`}>
<a>Page1</a>
</Link>
<p>Welcome to the page 2</p>
</div>
I did nothing just did this
href='/page1' to href='/'
or
href='/page1' to href='/page'
From the above scenarios, I used only one, now routing is working properly.
I am bit confused how it's working and I need proper explanation for this scenario.
Please help me out.
Thanks in advance