Route Groups Overview
Route groups use folder names wrapped in parentheses(name) to organize routes without affecting the URL structure. This allows you to:
- Apply different layouts to different sections
- Keep related pages organized
- Share loading states and error boundaries
(dashboard)/settings/page.tsx becomes /settings, not /dashboard/settings
Route Structure
Route Group Details
(marketing) — Public Pages
Location:src/app/(marketing)/Layout:
src/app/(marketing)/layout.tsxFeatures: Header navigation, footer, no auth required Routes:
| Path | File | Purpose |
|---|---|---|
/ | (marketing)/page.tsx | Landing page |
/features | (marketing)/features/page.tsx | Features page |
/pricing | (marketing)/pricing/page.tsx | Pricing plans |
/about | (marketing)/about/page.tsx | About page |
/docs | (marketing)/docs/page.tsx | Docs redirect |
/blog | (marketing)/blog/page.tsx | Blog index |
/blog/[slug] | (marketing)/blog/[slug]/page.tsx | Blog post detail |
(auth) — Authentication Pages
Location:src/app/(auth)/Layout:
src/app/(auth)/layout.tsxFeatures: Centered layout, Clerk components Routes:
| Path | File | Purpose |
|---|---|---|
/sign-in | (auth)/sign-in/[[...sign-in]]/page.tsx | Clerk sign-in UI |
/sign-up | (auth)/sign-up/[[...sign-up]]/page.tsx | Clerk sign-up UI |
[[...sign-in]] syntax creates optional catch-all routes, allowing Clerk to handle sub-paths like /sign-in/verify-email.
Layout structure:
(dashboard) — Protected Pages
Location:src/app/(dashboard)/Layout:
src/app/(dashboard)/layout.tsxFeatures: Sidebar navigation, authentication required, user sync Routes:
| Path | File | Purpose |
|---|---|---|
/dashboard | (dashboard)/dashboard/page.tsx | Main dashboard |
/dashboard/chat | (dashboard)/dashboard/chat/page.tsx | AI chat interface |
/dashboard/files | (dashboard)/dashboard/files/page.tsx | File management |
/onboarding | (dashboard)/onboarding/page.tsx | New user onboarding |
(legal) — Legal Pages
Location:src/app/(legal)/Layout:
src/app/(legal)/layout.tsxFeatures: Minimal layout, static content Routes:
| Path | File | Purpose |
|---|---|---|
/privacy | (legal)/privacy/page.tsx | Privacy policy |
/terms | (legal)/terms/page.tsx | Terms of service |
/cookies | (legal)/cookies/page.tsx | Cookie policy |
waitlist — Standalone Page
Location:src/app/waitlist/page.tsxPath:
/waitlistLayout: Uses root layout (no route group) Pages outside route groups use the root layout directly.
Dynamic Routes
Blog Post Detail
Path:/blog/[slug]File:
src/app/(marketing)/blog/[slug]/page.tsx
/blog/getting-started→params.slug = "getting-started"/blog/nextjs-tips→params.slug = "nextjs-tips"
API Routes
Location:src/app/api/Convention:
route.ts files export HTTP method handlers
Health Check
File:src/app/api/health/route.tsPath:
GET /api/health
Email API
File:src/app/api/email/route.tsPath:
POST /api/emailAuth: Clerk middleware
Chat API
File:src/app/api/chat/route.tsPath:
POST /api/chatFeatures: Streaming responses via Vercel AI SDK
Navigation Patterns
Link Component
Use Next.jsLink for client-side navigation:
Programmatic Navigation
UseuseRouter for navigation in event handlers:
Redirect
Useredirect() in Server Components:
Route Protection
Clerk Middleware
Protect routes viamiddleware.ts:
/dashboard, /onboarding, /dashboard/chat, /dashboard/filesPublic routes:
/, /features, /pricing, /blog, /sign-in, /sign-up
Client-side Protection
UseuseAuth() hook for conditional rendering:
Onboarding Flow
Shipr includes automatic onboarding redirection for new users: Hook:src/hooks/use-onboarding.ts
SEO & Metadata
Static Metadata
Dynamic Metadata
Generated Routes
Sitemap
File:src/app/sitemap.tsPath:
/sitemap.xml
Robots.txt
File:src/app/robots.tsPath:
/robots.txt
Next Steps
Architecture
Learn about the tech stack and architectural decisions
Project Structure
Explore the directory structure and file organization
Providers
Deep dive into the provider stack configuration
Authentication
Set up and customize Clerk authentication