Repository: sveltejs/kit

Issue #669: $page.query.get(..) returns null for prerendered pages
Created: 2021-03-25T12:14:13Z
Describe the bug
$page.query.get(...) returns null.
To Reproduce

Repository: https://github.com/falsetru/sveltekit-test/tree/issue-1

git clone --branch issue-1 https://github.com/falsetru/sveltekit-test.git issue-1
cd issue-1
npm install
npm run build
npx sirv build/  # `npm run start` will hide the issue.


Run above commands
Visit http://localhost:5000/?name=abc

Expected behavior
abc printed, but got null.
Information about your SvelteKit Installation:

  Diagnostics

The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers

  System:
    OS: Linux 5.8 Ubuntu 20.10 (Groovy Gorilla)
    CPU: (4) x64 Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
    Memory: 763.02 MB / 15.39 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.18.2 - /usr/bin/node
    npm: 7.7.6 - ~/.npm-packages/bin/npm
  Browsers:
    Chrome: 89.0.4389.114
    Firefox: 87.0
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.67 
    svelte: ^3.29.0 => 3.37.0 
    vite: ^2.1.0 => 2.1.5 



Your browser
Google Chrome Version 89.0.4389.114 (Official Build) (64-bit)


Your adapter
@sveltejs/adapter-static



Additional context

As a workaround, I am using new URLSearchParams(document.location.search).get('name').
If I modify 
  
    
      kit/packages/kit/src/runtime/server/page.js
    
    
         Line 398
      in
      4a1c04a
    
  
  
    

        
          
           					query: new URLSearchParams(${s(request.query.toString())}), 
        
    
  

 to
query: new URLSearchParams(document.location.search),
the issue is gone. Not sure whether it's proper way.

Duplicate issue #2081: Query params null on initial load with adapter-static
Created: 2021-08-03T13:41:06Z
Describe the bug
When using the page store from $app/stores in conjunction with adapter-static and uploading to GCP storage, the initial load of the page does not have the correct query parameters.
The query parameter works correctly both with svelte-kit dev and svelte-kit build && svelte-kit preview.
This issue seems related from #969
Reproduction
index.svelte
<script context="module">
import { page } from '$app/stores';
</script>

<h1>Query: {$page.query.get('search')}</h1>

URL: http://kit-query.storage.googleapis.com/index.html?search=test
svelte.config.js
Logs
No response
System Info
npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
npx: installed 1 in 0.676s

  System:
    OS: Linux 5.13 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
    Memory: 10.66 GB / 15.58 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.21.0 - ~/.nvm/versions/node/v12.21.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v12.21.0/bin/yarn
    npm: 6.14.11 - ~/.nvm/versions/node/v12.21.0/bin/npm
  npmPackages:
    @sveltejs/eslint-config: github:sveltejs/eslint-config#v5.7.0 => 5.7.0
Severity
annoyance
Additional Information
I'd be happy to submit a PR to fix this issue but I need a little help knowing where to start.

Closing comment (2021-08-03T13:43:47Z): Duplicate of #669