Force Browser Navigation in Svelte
- 1 minute read
By default, when a link on the same domain on a SvelteKit site is clicked, the page is rehydrated instead of triggering a full browser navigation.
However, there are times when you might want to trigger a full browser navigation without rehydrating the current page.
To manually override this behavior, all you need to do is add rel=“external” to your anchor tags:
<a href="/" rel="external">Example</a>
The rel
attribute is not new to Svelte, and the
external value isn’t anything new either.
The external
value normally indicates that the link to which it has been applied points to a page on an external (different) site.
Conclusion
Anyway, that’s all! If you’ve been having issues with page rehydration following user navigation in SvelteKit, this might help.