Bird
Raised Fist0
Svelteframework~20 mins

Route groups in Svelte - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Route Groups Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
1:30remaining
How does a route group affect URL paths in SvelteKit?

Consider a SvelteKit app with a route group folder named (admin) containing a page dashboard.svelte. What URL path will render this page?

Svelte
src/routes/(admin)/dashboard.svelte
A/dashboard
B/admin/dashboard
C/(admin)/dashboard
D/dashboard/(admin)
Attempts:
2 left
💡 Hint

Route groups in parentheses do not add to the URL path.

📝 Syntax
intermediate
1:30remaining
Identify the invalid route group folder name

Which folder name is NOT valid for a route group in SvelteKit?

A[group]
B(user-settings)
C(profile)
D(dashboard)
Attempts:
2 left
💡 Hint

Route groups must be wrapped in parentheses, not square brackets.

❓ state_output
advanced
2:00remaining
What is the rendered output path for nested route groups?

Given this folder structure in SvelteKit:

src/routes/(app)/(dashboard)/stats.svelte

What URL path will render stats.svelte?

A/stats/(app)/(dashboard)
B/app/dashboard/stats
C/(app)/(dashboard)/stats
D/stats
Attempts:
2 left
💡 Hint

Route groups do not add segments to the URL path, even when nested.

🔧 Debug
advanced
2:00remaining
Why does this route group cause a 404 error?

In a SvelteKit app, a developer creates a folder named (admin-panel) with a page index.svelte. The URL /admin-panel returns 404. Why?

Svelte
src/routes/(admin-panel)/+page.svelte
AThe file must be named 'admin-panel.svelte' to match the URL.
BRoute groups do not add to the URL, so '/admin-panel' does not match any route.
CThe folder name must not contain a hyphen inside parentheses.
DRoute groups require a +page.svelte file, not index.svelte.
Attempts:
2 left
💡 Hint

Think about how route groups affect URL paths.

🧠 Conceptual
expert
2:30remaining
What is the main purpose of route groups in SvelteKit?

Why would a developer use route groups (folders with parentheses) in a SvelteKit project?

ATo automatically generate nested layouts for each group.
BTo create dynamic URL segments for parameters.
CTo organize routes without changing the URL structure.
DTo enable server-side rendering only for grouped routes.
Attempts:
2 left
💡 Hint

Consider how route groups affect URLs and project structure.

Practice

(1/5)
1. What is the main purpose of using route groups in a SvelteKit project?
easy
A. To change the URL path of routes automatically
B. To add styles to routes
C. To organize routes without changing the URL structure
D. To create API endpoints

Solution

  1. Step 1: Understand route groups concept

    Route groups in SvelteKit are folders with parentheses that help organize routes.
  2. Step 2: Identify effect on URL

    Route groups do not affect the URL path; they only organize files internally.
  3. Final Answer:

    To organize routes without changing the URL structure -> Option C
  4. Quick Check:

    Route groups = organize routes, no URL change [OK]
Hint: Remember: parentheses folders group routes but keep URLs same [OK]
Common Mistakes:
  • Thinking route groups change URLs
  • Confusing route groups with styling
  • Assuming route groups create API endpoints
2. Which folder name correctly creates a route group in SvelteKit?
easy
A. (admin)
B. user_profile
C. blog(posts)
D. [settings]

Solution

  1. Step 1: Identify route group syntax

    Route groups use parentheses around folder names, like (group).
  2. Step 2: Check options

    Only (admin) uses parentheses correctly: (admin).
  3. Final Answer:

    (admin) -> Option A
  4. Quick Check:

    Parentheses folder = route group [OK]
Hint: Look for folder names wrapped in parentheses [OK]
Common Mistakes:
  • Using square brackets instead of parentheses
  • Not using any brackets
  • Placing parentheses incorrectly
3. Given this folder structure in SvelteKit:
src/routes/(dashboard)/stats/+page.svelte
src/routes/(dashboard)/settings/+page.svelte

What will be the URL path to access the stats page?
medium
A. /(dashboard)/stats
B. /stats
C. /stats/dashboard
D. /dashboard/stats

Solution

  1. Step 1: Understand route groups effect on URL

    Folders in parentheses do not appear in the URL path.
  2. Step 2: Determine URL for stats page

    The stats folder is inside the group, so URL is just /stats.
  3. Final Answer:

    /stats -> Option B
  4. Quick Check:

    Route groups hide folder name in URL [OK]
Hint: Ignore parentheses folders when reading URLs [OK]
Common Mistakes:
  • Including group folder name in URL
  • Confusing parentheses with URL segments
  • Assuming group name appears in URL
4. You created a folder named (admin) inside src/routes but your routes inside it are not working. What is a likely cause?
medium
A. You forgot to add a +page.svelte file inside the group folder
B. Parentheses are not allowed in folder names
C. Route groups must be named with square brackets
D. You need to restart the server after creating route groups

Solution

  1. Step 1: Check route group folder requirements

    Route groups organize routes but need actual route files like +page.svelte inside.
  2. Step 2: Identify missing file issue

    If no +page.svelte or route file exists, routes won't work.
  3. Final Answer:

    You forgot to add a +page.svelte file inside the group folder -> Option A
  4. Quick Check:

    Route groups need route files to work [OK]
Hint: Always add +page.svelte inside route groups [OK]
Common Mistakes:
  • Thinking parentheses folders are invalid
  • Using wrong bracket types
  • Assuming server restart fixes missing files
5. You want to group routes for profile and settings under a common group without changing their URLs. Which folder structure achieves this correctly?
hard
A. src/routes/(user-profile-settings)/+page.svelte
B. src/routes/user/profile/+page.svelte and src/routes/user/settings/+page.svelte
C. src/routes/[user]/profile/+page.svelte and src/routes/[user]/settings/+page.svelte
D. src/routes/(user)/profile/+page.svelte and src/routes/(user)/settings/+page.svelte

Solution

  1. Step 1: Understand grouping without URL change

    Route groups use parentheses folders to group routes without affecting URLs.
  2. Step 2: Analyze folder structures

    src/routes/(user)/profile/+page.svelte and src/routes/(user)/settings/+page.svelte uses (user) folder to group profile and settings routes without adding /user to URLs.
  3. Final Answer:

    src/routes/(user)/profile/+page.svelte and src/routes/(user)/settings/+page.svelte -> Option D
  4. Quick Check:

    Parentheses folder groups routes, no URL change [OK]
Hint: Use parentheses folders to group routes invisibly [OK]
Common Mistakes:
  • Using normal folders which add to URL
  • Using square brackets which create dynamic routes
  • Placing all routes in one file
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard