Given a SvelteKit route file named src/routes/blog/[slug].svelte with the following code, what will be displayed when navigating to /blog/hello-world?
<script> export let params; </script> <h1>Blog Post: {params.slug}</h1>
Dynamic route parameters are passed as params to the component.
The [slug] in the filename captures the URL part after /blog/ and passes it as params.slug. So navigating to /blog/hello-world sets params.slug to hello-world.
Choose the option that correctly accesses the dynamic route parameter id in a file named src/routes/user/[id].svelte.
Dynamic parameters are passed as params props to the page component.
In SvelteKit, dynamic route parameters are passed as params to the page component as props. So you must declare export let params; and then access params.id.
currentId after navigation?Consider this SvelteKit component in src/routes/product/[id].svelte:
<script>
export let params;
let currentId = params.id;
</script>
<h2>Product ID: {currentId}</h2>If the user navigates from /product/123 to /product/456 without a full page reload, what will be the value of currentId?
Think about how export let params works with client-side navigation.
The params prop is set only when the component is created. Navigating client-side does not recreate the component, so currentId remains the initial value 123. To update on navigation, you must react to params changes.
Given this SvelteKit component src/routes/[slug].svelte:
<script>
export let params;
</script>
<p>Slug: {params.slug}</p>When navigating to /hello, the page shows Slug: (empty). What is the most likely cause?
Check how props are declared in Svelte components.
In SvelteKit, dynamic route parameters are passed as props named params. To access them, you must declare export let params;. Without this, params is undefined, so params.slug is empty.
Consider these two route files in SvelteKit:
src/routes/shop/[category]/[item].sveltesrc/routes/shop/[category]/index.svelte
If a user navigates to /shop/electronics/phone, which parameters are available in [item].svelte and what are their values?
Think about how nested dynamic segments combine their parameters.
SvelteKit merges all dynamic parameters from the full route path. So in /shop/electronics/phone, params.category is electronics and params.item is phone in the [item].svelte component.