Introduction
Route groups help organize your app's pages without changing the URL. They keep your routes tidy and easy to manage.
Route groups help organize your app's pages without changing the URL. They keep your routes tidy and easy to manage.
src/routes/(groupName)/+page.svelte
/ for the root page.src/routes/(dashboard)/+page.svelte
/settings, not /dashboard/settings.src/routes/(dashboard)/settings/+page.svelte
/users.src/routes/(admin)/users/+page.svelte
Both pages are inside the (app) group folder. The URLs are / for the root page and /about for about page. The group name does not appear in the URL.
// Folder structure: // src/routes/(app)/+page.svelte // src/routes/(app)/about/+page.svelte // src/routes/(app)/+page.svelte <script> export let name = 'Home'; </script> <h1>Welcome to {name} page</h1> // src/routes/(app)/about/+page.svelte <h1>About Us</h1> <p>This page is grouped but URL is /about</p>
Route groups only affect folder structure, not the URL path.
You can nest route groups inside each other for complex apps.
Use route groups to share layouts or data loading logic easily.
Route groups organize routes without changing URLs.
Use parentheses around folder names to create groups.
They help keep your project clean and maintainable.
route groups in a SvelteKit project?(group).(admin).src/routes/(dashboard)/stats/+page.svelte
src/routes/(dashboard)/settings/+page.svelte
stats page?stats folder is inside the group, so URL is just /stats.(admin) inside src/routes but your routes inside it are not working. What is a likely cause?+page.svelte inside.+page.svelte or route file exists, routes won't work.profile and settings under a common group without changing their URLs. Which folder structure achieves this correctly?(user) folder to group profile and settings routes without adding /user to URLs.Pass the test and this pattern moves unknown