Ordered url params
See original GitHub issueDescribe the problem
It’s currently impossible to have information about the order of url params.
Say i have the following path: /anything/${id}/${otherId}, and i want to display in a breadcrumbs component content related to each id and otherId (for instance a name, fetched from a distant api).
$page.params gives {id, otherId}, which can be used to get a reverse mapping between the slug values in the path and the name of each param, helpful to know what to do with each value (basically fetch data).
But what if id and otherId actually are the same value, 1 for instance ? In this case, the reversing mapping would be broken, since we’d get {1: 'otherId'}, and lose the info about id.
Describe the proposed solution
Maybe make an orderedParams available in InputProps and page store.
It would provide [{slug: 'id', value: 1}, {slug: 'otherId', value: 1}], or even just ['id', 'otherId'].
Alternatives considered
Hope all the ids are unique.
Importance
nice to have
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)

Top Related StackOverflow Question
Have you tried doing
for (const paramName in Object.keys(params))? I haven’t yet checked the Svelte-Kit source, but I believe theparamsobject will have its keys set in left-to-right order. And while Javascript used to not guarantee the order of iteration, I believe it’s been guaranteed since ES2015 that object properties will be iterated in insertion order. So you might already have theorderedParamsthat you’re looking for, simply by usingObject.keys. It may not be guaranteed in the Svelte-Kit documentation, but it’s very unlikely to change.Correct, the keys will enumerate left-to-right. In any case, https://github.com/sveltejs/kit/pull/4345 will make the
routeIdavailable, which solves this problem — closing this