sveltejs / sveltejs/kit

`page.data` mutable in legacy mode

Open
#13,178 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

svelte 5
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

I found that the new page.data is mutable in legacy mode but not in rune mode.

Reproduction

Can't import from the new '$app/state` module in Sveltelab for unknown reasons (Kit updated). So here is the code:

//+page.server.ts
export async function load() {
    return { random: Math.random() }
}
<script lang="ts">
	import { page } from '$app/state';
</script>

{page.data.random}
<button onclick={() => page.data.random++}> Increment </button>
Logs

No response

System Info
N/A
Severity

annoyance

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided +page.server.ts load function and the page.data example, comparing behavior in legacy and rune modes. Trace the page state handling that permits the legacy mutation and verify that the reproduction no longer allows page.data.random++ to mutate the loaded data.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.