Add a Dashboard Page
The dashboard uses a section-switcher pattern inside a single page at src/app/[locale]/dashboard/page.tsx.
This guide explains how to add a new section while keeping navigation, localization, and the switcher logic aligned with the current architecture.
Before adding a dashboard section
Review Project Structure first so the new section keeps component, sidebar, and service boundaries in the right places.
What this guide covers
Section creation
How to create a new section component and register it in the dashboard page switcher.
Sidebar registration
How to add a navigation entry in the sidebar so users can switch to the new section.
Data boundaries
How to keep data loading, API access, and reusable business logic in the right layers.
Main files and folders
| File | Propósito |
|---|---|
src/app/[locale]/dashboard/<segment>/page.tsx | Dashboard page. |
src/config/dashboard.ts | Dashboard section definitions. |
messages/*.json | Localized dashboard labels. |
src/app/[locale]/dashboard/_components/sidebar.tsx | Dashboard sidebar. |
Steps
1. Create the section component
Add a new section file in the dashboard features folder:
src/features/dashboard/<name>-section.tsx
2. Add the section to the switcher
Open src/features/dashboard/dashboard-page.tsx and add a new conditional render for your section:
{section === "<name>" ? <YourSection /> : null}
This registers the section in the page so the sidebar can activate it.
3. Add a navigation entry to the sidebar
Open src/features/dashboard/sidebar.tsx and add an entry for your new section with:
- section identifier
- label (or translation key)
- icon
The sidebar is the single source of truth for dashboard navigation.
4. Add translation keys
Add the matching label key to all message files used by the dashboard sidebar.
5. Add data loading
Use:
- server components for page-level data loading when possible
- tRPC protected procedures for authenticated server access
src/server/serviceswhen domain logic grows beyond the page
6. Verify the full flow
After adding the section, test:
- sidebar navigation switches to the new section
- sidebar highlighting is correct
- localized label rendering
- authenticated access and redirect behavior
- responsive sidebar behavior on mobile and desktop
Keep the dashboard sidebar-driven
Register new sections in the sidebar and the page switcher instead of hardcoding navigation state inside the section component itself.