Skip to content

page.url.searchParams not set on first page land with static build #3650

@Axeldeblen

Description

@Axeldeblen

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 with http-server pacakge.

Logs

mount

null
mount
tag=navigated
navigated
mount
tag=backToHome
backToHome

System Info

System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 255.88 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.3 - ~/.nvm/versions/node/v14.17.3/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.3 - ~/.nvm/versions/node/v14.17.3/bin/npm
  Browsers:
    Brave Browser: 97.1.34.81
    Chrome: 97.0.4692.99
    Firefox: 94.0.2
    Safari: 14.1.2
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.17
    @sveltejs/adapter-static: ^1.0.0-next.26 => 1.0.0-next.26
    @sveltejs/kit: next => 1.0.0-next.251
    svelte: ^3.44.0 => 3.46.3

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions