onclicknavigationsvelte

How can i navigate to different path on click in svelte?


Currently in having on:click | preventDefault="{() => showDetail({id})}" and in showDetail function i want to naviagte to particular id which in i am passing on click of button.

I tried regular javascript methodlocation.assign but this is reloading the page and destroying the purpose of SPA. Is there any way to navigate in svelte without reloading


Solution

  • You need a router. There are SPA routers (Single Page Application) and SSR router (Server Side Rendering).

    You may try :