Skip to content

Cannot migrate page to app-state in module-level derived #17067

@AntonioVentilii

Description

@AntonioVentilii

Describe the bug

I am finishing migrating our project to Svelte 5 and I noticed that we need to migrate page from $app/stores to $app/state.

However, this causes an issue with derived stores in a TS module. In fact, page is not Readable anymore, so, it does not trigger any reactivity.

And it cannot be completely migrated to being consumed in each components, since there are other derived depending on the first derived, and so on and so forth.

It seems to be kind of a feature loss, or maybe is it an unexpected usage? What is the official migration guide here?

Note

I had raised the same issue with the migration script, but it was ultimately dismissed without a proper solution or guide. See #16758

Reproduction

Before

// ./nav.derived.ts

import { page } from '$app/stores';
import { derived, type Readable } from 'svelte/store';

export const routeCollection: Readable<string | undefined | null}> = derived(
	[page],
	([
		{
			data: { collection }
		}
	]) => collection
);

After

// ./nav.derived.ts

import { page } from '$app/state';
import { derived, type Readable } from 'svelte/store';

export const routeCollection: Readable<string | undefined | null}> = derived(
	[page], // <---- Property subscribe is missing in type [...] but required in type Readable<any>
	([
		{
			data: { collection }
		}
	]) => collection
);

System Info

System:
    OS: macOS 26.0.1
    CPU: (11) arm64 Apple M3 Pro
    Memory: 390.48 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.17.0 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.2 - /usr/local/bin/npm
    pnpm: 10.12.1 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 142.0.7444.60
    Firefox: 144.0.2
    Safari: 26.0.1
  npmPackages:
    svelte: ^5.41.0 => 5.41.0

Severity

blocking an upgrade

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