Challenge - 5 Problems
File-based Routing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ā component_behavior
intermediate2:00remaining
What component renders for the URL
/blog/42?Given this file structure in a SvelteKit project:
Which component will render when the user visits
src/routes/ āāā +page.svelte āāā blog/ ā āāā +page.svelte ā āāā [id]/+page.svelte āāā about/+page.svelte
Which component will render when the user visits
/blog/42?Attempts:
2 left
š” Hint
Dynamic segments in file names match URL parts like numbers or words.
ā Incorrect
The URL /blog/42 matches the dynamic route [id] inside the blog folder. So src/routes/blog/[id]/+page.svelte renders.
š Syntax
intermediate2:00remaining
Which file name correctly defines a catch-all route?
In SvelteKit file-based routing, which file name correctly matches all routes under
/docs, including nested paths like /docs/intro/setup?Attempts:
2 left
š” Hint
Catch-all routes use three dots inside square brackets.
ā Incorrect
The catch-all route syntax uses [...name] to match any nested path segments. So [...all] is correct.
š§ Debug
advanced2:00remaining
Why does
/profile show a 404 error?Given this file structure:
Visiting
src/routes/ āāā +page.svelte āāā profile/[user]/+page.svelte
Visiting
/profile shows a 404 error. Why?Attempts:
2 left
š” Hint
The route folder must contain a +page.svelte file directly for the path to work.
ā Incorrect
In SvelteKit, to serve /profile, the file src/routes/profile/+page.svelte must exist. If profile is a folder, the file must be inside it as +page.svelte. The correct is to have profile/+page.svelte as a file inside the folder.
ā state_output
advanced2:00remaining
What is the value of
params.id for URL /shop/123?Given this file:
What will be displayed when visiting
src/routes/shop/[id]/+page.svelte with this script:<script>
export let params;
</script>
<p>ID: {params.id}</p>What will be displayed when visiting
/shop/123?Attempts:
2 left
š” Hint
Dynamic segments in the file name become keys in the params object.
ā Incorrect
The dynamic segment [id] captures the URL part 123 and passes it as params.id.
š§ Conceptual
expert3:00remaining
Which file handles the route
/dashboard/settings/profile?Given this file structure:
Which file is responsible for rendering the content at
src/routes/ āāā dashboard/+layout.svelte āāā dashboard/settings/+page.svelte āāā dashboard/settings/profile/+page.svelte āāā dashboard/settings/profile/+layout.svelte
Which file is responsible for rendering the content at
/dashboard/settings/profile?Attempts:
2 left
š” Hint
Layouts wrap pages but do not replace them.
ā Incorrect
The +page.svelte file renders the page content. Layouts wrap around pages to provide shared UI but do not replace the page content.