-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
page.url.searchParams not set on first page land with static build #3650
Comments
See #2361/#2444. It's intended that this not be accessible during pre-rendering (and thus not during static rendering either), because there's no way to have separate rendered static files for the same pathname and different query parameters. I'm not sure why #3314 isn't correctly throwing an error when you do this, however. |
Right I see what you mean now, cheers for the reply. Would it be possible to intentionally hydrate the page store after the initial load? I guess that would have its own potential downfalls but at least it would help any components work as intended that rely on the query params. That could avoid any future confusion in these kind of cases. edit: I found this comment from Rich which describes the problem / solutions - #2363 (comment) It did actually throw the build error when I had the same logs in the script body e.g
|
DId you try to pass down from the
|
Describe the bug
$page store is not set on initial landing when building site with the static adapter. Further navigation around the site when adding query strings works as intended. As an example where the query string is console logged
onMount
You go to site-example.com/?tag=help
$page.url.searchParams.get('tag') is equal to null
you click a link to site-example.com/page2/?tag=red
$page.url.searchParams.get('tag') is equal to 'red'
you click taking you back to the root path site-example.com/?tag=blue
$page.url.searchParams.get('tag') is equal to 'blue'
This issue seems to only be reproduced when the site is deployed. Running the site in preview mode does not reproduce the issue.
Reproduction
I've deployed the example repo with surge, open the console to see the logs.
Example repo is a create-svelte clone with the addition of the static adapter
https://cautious-cars-123.surge.sh/?tag=sendHelp
https://github.com/Axeldeblen/static-build-test
issue can also be created by serving the files without vite, for example in the repo run
npm run build && npm run http-serve
to serve the build output withhttp-server
pacakge.Logs
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: