Skip to content

Location State store #1641

Closed
Closed
@dkzlv

Description

@dkzlv

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions