0

I am using a component to render a page, and I am using dynamic routes. I am pre-rendering using getServerSideProps, and now data of the page can change based on the route.

When the page is first loaded, the SSR returns HTML and the data and correctly renders the page.

When I click on the link present on the page in Link tag of next js, getServerSideProps returns a json object, but not the HTML so the data changes, but the component fails to re-render/ or the data on the page is still old one.

If I use anchor <a> tag in place of link tag then the page refreshes and it is working but it do not give a single page application feeling.

I tried router.replace(router.asPath) in the component, but that do not work. only changing link tag with a tag works but that refreshes the full page and the experience is not good.

Aurovrata
  • 2,000
  • 27
  • 45

0 Answers0