fix: restore history.state on refresh#12409
Conversation
Fix the issue with history.state resetting on refresh
|
|
this seems to be an area that's difficult to get right, so I'd really want to have a test for this one |
|
The maintainers probably haven't discussed this yet, but I think this should be optional as Rich mentioned in the issue. |
I don't understand. Why should the framework's default behavior be to block the implementation of basic browser functionality? If a user is building a complex multi-page signup process, they can use history.state to store personal information within the history to preserve it even after a refresh without relying on a store. This history.state can store not only simple objects but also data like files selected through a form. Blocking this forces the use of localstorage. It's natural that this doesn't work in SSR since it's a browser feature. Isn't it up to the developers using this framework to handle such implementations? The current implementation in Kit2 blocks this, taking away the user's choice. Our service has been unable to upgrade to Kit2 since last year due to this issue. |
|
The current behavior of SvelteKit 2, which resets Blocking basic browser functionality imposes unnecessary constraints on developers. While it is understandable that Moreover, the current implementation in SvelteKit 2 lacks the necessary flexibility. Instead of enforcing specific functionalities, the framework should allow developers to make their own choices. This flexibility is crucial for supporting a wide range of use cases. The inability of certain services to upgrade to SvelteKit 2 due to this restriction highlights the real problems this limitation can cause. Overall, the current implementation of SvelteKit 2, which restricts the use of |
history.state on refresh
|
This can't be merged in its current state, per #12409 (comment). At minimum there needs to be an option for it. But honestly I'm still not totally convinced it's a good idea — I'm not sure The big caveat is that it's backed by (A smaller caveat is that Notably, the |
fixes? #11956
fixes #9868
Fix the issue with history.state resetting on refresh
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits