-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add data-sveltekit-replace link option #9014
Copy link
Copy link
Closed
Labels
feature / enhancementNew feature or requestNew feature or requestlow hanging fruitready to implementplease submit PRs for these issues!please submit PRs for these issues!
Milestone
Description
Describe the problem
If you want create a navigation where the navigation history is replaced, you always have to use goto with the replace option instead of an <a> link.
This means you lose a few benefits:
- The ability to middle-click or cmd+click to open the link in a new tab
- easy preloading of code/data with their corresponding link options
- instead you have to call
preloadData/preloadCodewithin anon:clickcall before yourgotocall - if you want the preload call to happen on hover/tap instead, you need more handlers on top
- instead you have to call
- easier a11y compliance -> instead should manually describe the role/purpose of the button (or whatever component is being used)
- any automatic link scraping that you might have set up for SEO/sitemap generation/whatever else
Describe the proposed solution
An additional data-sveltekit-replace option on top of the existing options.
This would turn something like this:
<button
on:click={() => goto('/my-path/123', { replaceState: true })}
on:touchstart={() => preloadData('/my-path/123')}
on:mousedown={() => preloadData('/my-path/123')}
>
Go to page
</button>into this:
<a href="/my-path/123" data-sveltekit-replace data-sveltekit-preload-data="tap">
Go to page
</a>Alternatives considered
Using goto as described above.
Importance
would make my life easier
Additional Information
A related comment was made in another somewhat related issue here.
I tried looking for other discussions on this feature and couldn't find any - sorry if I missed one!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature / enhancementNew feature or requestNew feature or requestlow hanging fruitready to implementplease submit PRs for these issues!please submit PRs for these issues!