Skip to content

Add a way to change the query params on a page easily. #969

@davjhan

Description

@davjhan

Is your feature request related to a problem? Please describe.
I would like an easy way to change the query params in the address bar at runtime.

Usecases:

  • I want to sync a text input on the page to a query param so that when the user copies the address from the address bar and shares it, the link automatically has the field pre-filled.
  • I want to pass an error message to another page that I want to display temporarily. I set the error as a query param and use goto to redirect to that page. If i let the user acknowledge the error banner and hide it, I want to remember that by stripping the query param from the URL so that when they refresh, the banner doesn't re-appear.

Describe the solution you'd like
An API that allows me to change the url, with convenient syntax for adding and removing query params. Ideally, this will not trigger a refresh of the page in itself.

Perhaps augment the goto API? https://kit.svelte.dev/docs#modules-app-navigation
Describe alternatives you've considered
There are workarounds for the usecases that I've mentioned, but this is a common enough usecase imo.

How important is this feature to you?
Not a deal-breaker but it would allow me to have a simpler architecture that stores state more obviously, in the url, instead of a store.
Additional context
As an aside, It would also be nice to have a slicker way to append query params to a goto call. Currently, judging by the signature from the documentation, theres no way to do it.

goto(href, { replaceState, noscroll })

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions