Skip to content

page.params from $app/state is not reactive where as from $app/stores is reactive #13305

@mkmoisen

Description

@mkmoisen

Describe the bug

I apologize if this is something simple, I have read the documentation on $app/state/page and believe that this should work the same as it does for $app/stores/state but it does not.

It seems that $app/state/page lacks the reactivity that $app/stores/page has.

/foos
    [fooId]
        +page.svelte
<script>
    import { page } from '$app/state';
    
    $: fooId = page.params.fooId;
</script>

<h1>{fooId}</h1>

<a href="/foos/1">1</a>
<a href="/foos/2">2</a>

Clicking on the link here will no longer cause the page.params.fooId to change. The URL is correctly updated when clicking on the link, but $fooId = page.params.fooId does not react.

This works works fine when using { page } from '$app/stores':

    import { page } from '$app/stores';
    $: fooId = $page.params.fooId;

Reproduction

/foos
    [fooId]
        +page.svelte
<script>
    import { page } from '$app/state';
    
    $: fooId = page.params.fooId;
</script>

    <h1>{fooId}</h1>

    <a href="/foos/1">1</a>
    <a href="/foos/2">2</a>

Logs

No response

System Info

npmPackages:
    @sveltejs/adapter-static: ^3.0.6 => 3.0.8
    @sveltejs/kit: ^2.0.0 => 2.15.2
    @sveltejs/vite-plugin-svelte: ^4.0.0 => 4.0.4
    svelte: ^5.0.0 => 5.16.6
    vite: ^5.4.11 => 5.4.11

Severity

blocking an upgrade

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions