sveltekit-search-params
sveltekit-search-params copied to clipboard
Updating to SvelteKit 2 leads to warning
Describe the bug
We just updated from "@sveltejs/kit": "^1.24.1"
to "@sveltejs/kit": "^2.5.0"
and started getting the warning:
Avoid using
history.pushState(...)
andhistory.replaceState(...)
as these will conflict with SvelteKit's router. Use thepushState
andreplaceState
imports from$app/navigation
instead.
Reproduction
This just happens every time we write to the query-params.
Logs
No response
Which version of this library you are using?
using "sveltekit-search-params": "2.1.0"
, I have also the same thing after removing all replaceState
in my own code.
I guess that it's coming from sveltekit-search-params
using
"sveltekit-search-params": "2.1.0"
, I have also the same thing after removing allreplaceState
in my own code. I guess that it's coming fromsveltekit-search-params
If you try to search the codebase there's no instance of replaceState except for the option that i pass to goto
but i explored sveltekit code and it's actually using history.replaceState under the hood.
Maybe i should use replaceState
instead of passing the option to goto
but that would introduce conflicts with previous versions of sveltekit
I didn't look too much into it.
Would be great if sveltekit warning tells us from where it is 😁
I just tryed to use replaceState if available...unfortunately it doesn't work because it doesn't propagate changes to the $page
store which the library rely on.
Thx for the test.
That mean that you also have the warn
in the console?
Actually I didn't saw a warn in the console...but regardless there's nothing that I can do (except fixing upstream) on my side. :(
Last kit version release note:
- fix: prevent false positive history.pushState and history.replaceState warnings
I'll check that and let you know 👍
EDIT: it didn't change anything.