How does svelte kit get routing configuration #10308
-
I want to get the routing information (such as path, parameters, etc.) of the project through js, but I don't seem to find the relevant methods and APIs in the documentation, what should I do? |
Beta Was this translation helpful? Give feedback.
Answered by
ryanzoleta
Jul 3, 2023
Replies: 1 comment
-
Do you mean from the You can import the <script lang="ts">
import {page} from `$app/stores`;
</script>
<h1>Route: {$page.route.id}</h1>
<h1>Params: {JSON.stringify($page.url.searchParams.getAll('hello'))}</h1> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
baiwusanyu-c
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you mean from the
<script>
tag of a.svelte
file?You can import the
page
store from$app/stores
then call it to get the params and route id:https://learn.svelte.dev/tutorial/page-store