kit
kit copied to clipboard
Add `goto` options to `Navigation` object and/or offer a way to alter a navigation in progress
Describe the problem
I'm currently doing something very hacky because I cannot update the huge number of links on a page:
beforeNavigate(async ({ to, type, cancel }) => {
if (
(type === 'link' || type === 'goto') &&
addTokenOnNavigation
) {
const redirect = new URL(to.url);
redirect.searchParams.set('token', data.token);
cancel(); // Cancel original navigation
await goto(redirect); // Navigate to the altered url
}
});
This has many issues, but most importantly, there is no way to forward goto/link options such as noScroll/ data-sveltekit-noscroll.
Describe the proposed solution
Many solutions would solve my issue:
- Add an
optionsprop toNavigation, mirroringgoto.optionsstructure. - Add a
rewritefunction toBeforeNavigate, that basically doescancel+goto, and preserves all options
Alternatives considered
None
Importance
would make my life easier
Additional Information
No response
Somewhat related to #11223
Just saw the new reroute hook! It won't work here as I want the edit to be visible in the address bar