Description
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:
- pass state object in
goto
in the second argument - allow for passing state in the
<a>
tag in some property, likesveltekit:state={}
- 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.