Svelte · Junior · Question 72 of 76
How do you read the current URL or route params in a SvelteKit component?
<script>
import { page } from "$app/state";
</script>
<p>{page.url.pathname}</p>- ✓Correct answer: Import
pagefrom$app/stateand readpage.url,page.params,page.data - 2Use
window.locationduring SSR - 3Read
$pagefrom$app/stores(the only way)
Explanation
$app/state gives reactive values. $app/stores was the old store-based API; it was deprecated and removed in SvelteKit 3.