sveltesapper

when clicked on an href the new URL doesn't reload the page in Svelte


I'm currently trying to redirect the user to a new page when they clicked on a href link. The problem is that the url does change per se, but only when I manually hit "reload", the page actually refreshes and shows the new data.

How I build the href-link:

resultString += "<a href='/edition/id=" + this.note['name'][i]['hkg:persKey'] + "'>";
resultString += this.note['name'][i]['#text'];
resultString += "</a>";

The resultString then gets pushed to an array and is correctly read out in another component.

The problem is, that when redirected, the id in the url visibly changes and is updated in the url but the page doesn't reload.

for example: on page with 'id=xy' the URL is: '/edition/id=xy' and on this page, the href '/edition/id=z' is displayed. When clicking on this href, the url changes visibly to '/edition/id=z' but the page doesn't reload.

Does anyone know how to solve this?


Solution

  • This is a feature of Sveltekit. You could try adding rel=external to your links

    <a rel="external" href="path">Path</a>
    

    Source: https://kit.svelte.dev/docs/link-options#data-sveltekit-reload