Skip to content

How to Mutate URL without causing reload? #8540

You must be logged in to vote

I highly recommend using GET forms to implement this as SvelteKit will intercept and retain client-side navigation on form submission.
https://kit.svelte.dev/docs/form-actions#get-vs-post
Submitting the form will update the URL with the search parameters matching the input names and values.

<form action="/baz">
  <label>
    Query
    <input name="query">
  </label>
  <label>
    Sort
    <input name="sort">
  </label>
  <label>
    Order
    <input name="order">
  </label>
  <label>
    Page
    <input name="page">
  </label>
</form>

Otherwise, you can manually call goto instead of history.replaceState is a good way to maintain client-side navigation (no reloads).

For example:
https://st…

Replies: 1 comment

You must be logged in to vote
0 replies
Answer selected by 1MuhammadYahya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants