sveltejs / sveltejs/kit

Option to clear Snapshot from sessionStorage

Open
#9,614 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the problem

When using a Snapshot to store <form> <input> values when the user navigates away, there currently is no way of clearing those values from sessionStorage. In fact, the docs contain a warning regarding same.

Avoid returning very large objects from capture — once captured, objects will be retained in memory for the duration of the session, and in extreme cases may be too large to persist to sessionStorage.

After a <form> has successfully been submitted, there is no reason to keep these values in sessionStorage.

Describe the proposed solution

We would need access to a key so we can call sessionStorage.removeItem(key); or some other method of clearing the data from sessionStorage.

Alternatives considered

No response

Importance

nice to have

Additional Information

I'm currently using BeforeNavigate and AfterNavigate to save, restore and clear my own snapshots to avoid this issue.

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 by reading the Snapshot behavior and its sessionStorage documentation, then trace how BeforeNavigate and AfterNavigate save and restore snapshots. Define how callers can identify and clear a stored snapshot after successful form submission, and verify that clearing removes the associated sessionStorage data without breaking navigation restoration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.