Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location State store #1641

Closed
dkzlv opened this issue Jun 5, 2021 · 3 comments
Closed

Location State store #1641

dkzlv opened this issue Jun 5, 2021 · 3 comments
Labels
feature / enhancement New feature or request
Milestone

Comments

@dkzlv
Copy link
Contributor

dkzlv commented Jun 5, 2021

Is your feature request related to a problem? Please describe.

Currently Kit's router does not give access to location state and always pushes an empty object. It's only used internally to restore scroll position.
It seems that the router should not abstract away this feature, as it can be useful for many different cases (animation restoration, saving some screen state, passing state between routes, etc.).

Describe the solution you'd like

I would say, the API surface consists of 3 parts:

  1. pass state object in goto in the second argument
  2. allow for passing state in the <a> tag in some property, like sveltekit:state={}
  3. adding a new readable store in $app/stores that updates the value as you go back and forth the history and excludes internal properties along the way

Describe alternatives you've considered

n/a

How important is this feature to you?

I wouldn't say this feature is a deal-breaker, but I also think Kit shouldn't abstract away basic browser features.

Additional context

My only concern is that it doesn't play nice with SSR and with TypeScript. Other than that it can be the only elegant solution sometimes.

@benmccann
Copy link
Member

There was a PR for this in Sapper: sveltejs/sapper#1341. Unfortunately, we didn't get a chance to get it merged before switching development over to SvelteKit

@gustavopch
Copy link

I've explained how I use history state to control modals in #3236 (comment). I'm linking here because it may be useful for this discussion too.

@Rich-Harris Rich-Harris added this to the 1.0 milestone Apr 25, 2022
@Rich-Harris
Copy link
Member

Closing this in favour of #5478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants