Route Structure
The application follows this routing architecture:Route Groups
Route groups organize routes without affecting the URL structure. They’re created using parentheses(group-name).
Content Route Group
The(content) group contains documentation and blog pages:
src/app/(content)/docs/layout.tsx
/docs/getting-started (not /content/docs/getting-started)
Protected Route Group
The(protected) group requires authentication:
src/app/(protected)/layout.tsx
- Session check with redirect
- Persistent sidebar state via cookies
- User-specific UI elements
Catch-All Routes
Docs and blog use optional catch-all routes[[...slug]]:
src/app/(content)/docs/[[...slug]]/page.tsx
/docs- matches withslug = undefined/docs/getting-started- matches withslug = ['getting-started']/docs/frontend/routing- matches withslug = ['frontend', 'routing']
API Routes
API routes handle server-side logic:Search Endpoint
src/app/api/search/route.ts
Open Graph Image Generation
src/app/api/og/home/route.tsx
Layouts
Root Layout
The root layout wraps the entire application:src/app/layout.tsx
Nested Layouts
Layouts can be nested for route-specific UI:Navigation
Link Component
Use Next.jsLink for client-side navigation:
Programmatic Navigation
Redirects
Server-side redirects in Server Components:Metadata
Static Metadata
Dynamic Metadata
Route Rewrites
Proxy API requests to the backend:next.config.ts
/api/health are proxied to the Hono API server.
Best Practices
Use Server Components by Default
Use Server Components by Default
Keep components as Server Components unless client interactivity is needed. This reduces JavaScript sent to the client.
Organize with Route Groups
Organize with Route Groups
Group related routes together for shared layouts without affecting URLs:
Leverage Parallel Data Fetching
Leverage Parallel Data Fetching
Fetch data in parallel for better performance:
Use Loading and Error States
Use Loading and Error States
Provide loading and error UIs for better UX:
loading.tsx
error.tsx
Next Steps
Components
Learn about Shadcn UI components and patterns
Data Fetching
Master TanStack Query for client-side data fetching