Skip to content

feat: support custom values in page.state via transport hook - #16662

Merged
Rich-Harris merged 2 commits into
version-3from
page-state-custom-transport
Aug 5, 2026
Merged

Rich-Harris merged 2 commits into
version-3from
page-state-custom-transport

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

Supersedes #14129, closes #14128. Allows custom values to be part of page.state and survive reloading.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@pkg-svelte-dev

ghost commented Aug 5, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from c5360c6:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/c5360c615bc7e7e9a82782bfdea845c183a0631a

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16662

@changeset-bot

ghost commented Aug 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c5360c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot

ghost commented Aug 5, 2026

Copy link
Copy Markdown

@GauBen

ghost commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

You kept the test case! 😁

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, just a little confusing

state = popped.state;
} else {
const serialized_state = stringify(state);
state = parse(serialized_state);

ghost Aug 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to serialize state and then parse it and reassign it back? might be worth a comment to explain; it seems like work for the sake of work if you're just reading it

Comment on lines +2905 to +2906
const serialized_state = stringify(state);
state = parse(serialized_state);

ghost Aug 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here; this is a weird pattern

@Rich-Harris
Rich-Harris merged commit f36b3a4 into version-3 Aug 5, 2026
@Rich-Harris
Rich-Harris deleted the page-state-custom-transport branch August 5, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow custom objects in page.state

3 participants