Ability to imperatively parse the path params, at clientside runtime #1871
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Normally, client-side code would get the path params from
$page.params
. For pre-rendered pages however, those values are the values as they were at pre-render time, which isn't useful if you're using a single pre-rendered HTML artifact to handle an entire parameterized route with path params which vary at runtime.In such case, you'd want look at the details of the particular request, by inspecting
window.location
. This is fine for path and query string, but not currently possible for path params because we don't have the information about its pattern or param names.This simply adds that ability, and should be considered in conjunction with just-now submitted #1870.
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0