Skip to content

Query parameters in hash routing become permanent if used "as directed" #14592

@jjgmckenzie

Description

@jjgmckenzie

Describe the bug

In #13191 there is a spirited discussion between Rich and the author as to how to handle query parameters in hash based routing.

Again, that's your choice. I will not; I will get my query parameters from page.url.searchParams, because I don't like to do work that's already been done for me.

Originally posted by @Rich-Harris in #13191 (comment)

This implies that the intended "svelte" way to handle query parameters in hash based routing is with page.url.searchParams.

However -- when navigating between pages; the expected behaviour, ie, search parameters are deleted, does NOT occur. They become "permanent" search params.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-h6zoggpw?file=src%2Froutes%2F%2Blayout.svelte

  1. when opened, the footer says "You have no search params"
  2. click about page - "Your current query parameters are: aboutpage="
  3. click home - "Your current query parameters are: aboutpage="

Logs

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^6.0.0 => 6.1.1 
    @sveltejs/kit: ^2.22.0 => 2.43.7 
    @sveltejs/vite-plugin-svelte: ^6.0.0 => 6.2.1 
    svelte: ^5.25.0 => 5.39.8 
    vite: ^7.0.4 => 7.1.8

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions