What is the Dashboard?
The Dashboard is the protected, logged-in area of your app where users see their data, settings, and manage their account. Think of it like the “inside” of your application after someone signs in. Visual structure:- Left side: Collapsible sidebar with navigation menus
- Top bar: Notifications, theme toggle, and user profile menu
- Main area: Your dashboard pages (overview, settings, data tables, charts)
When a signed-out user tries to visit
/dashboard, they’re automatically redirected to /sign-in. When a signed-in user tries to visit /sign-in, they’re redirected back to /dashboard.How the Dashboard Works
The dashboard uses a layout wrapper pattern. Here’s what happens:1. Layout wraps everything
File:sabo/src/app/(dashboard)/dashboard/layout.tsx
This file creates the “shell” that appears on every dashboard page:
2. Pages use the layout automatically
Every page under/dashboard/* automatically gets wrapped by this layout.
Example: sabo/src/app/(dashboard)/dashboard/page.tsx (the main dashboard page at /dashboard)
/dashboard, you see:
- Sidebar (from layout) on the left
- DashboardHeader (top bar with breadcrumb, notifications, user menu)
- Your page content (cards, charts, tables)
3. Settings pages work the same way
File:sabo/src/app/(dashboard)/dashboard/settings/general/page.tsx
/dashboard/settings/general:
- Same sidebar and layout (from
layout.tsx) - Different page content (the settings form)
- Sidebar automatically highlights “Settings > General” as active
Key Components Explained
AppSidebar (Left Navigation)
Location:sabo/src/components/dashboard/app-sidebar.tsx
What it contains:
- Team Switcher (top) - Switch between teams/workspaces
- Main Navigation - Primary menu items with collapsible sub-items
- Projects List - Quick access to projects
- Secondary Links - Support, Feedback
- User Menu (bottom) - Profile and sign out
app-sidebar.tsx:
Sidebar Documentation
Learn how to customize the sidebar navigation and structure.
DashboardHeader (Top Bar)
Location: Exported fromlayout.tsx
What it contains:
- SidebarTrigger - Button to toggle sidebar (especially on mobile)
- Breadcrumb - Shows current location (e.g., “Overview” or “Settings > Account”)
- NotificationsDropdown - Bell icon with notification count
- ModeToggle - Light/dark theme switcher
- HeaderUserMenu - Avatar dropdown with profile links and sign out
Settings Pages
Location:sabo/src/app/(dashboard)/dashboard/settings/*
Four built-in settings pages:
| Page | URL | What it does |
|---|---|---|
| General | /dashboard/settings/general | Profile info, display name, bio |
| Account | /dashboard/settings/account | Email, password, delete account |
| Billing | /dashboard/settings/billing | Subscription plan, payment history |
| Notifications | /dashboard/settings/notifications | Email/push notification toggles |
UserProfiletable - stores profile dataUserSubscriptiontable - stores Stripe subscription infoPaymentHistorytable - stores invoice records
Settings Documentation
Learn how settings pages connect to Supabase and how to customize them.
File Structure Map
How Pages Connect Together
Example: Clicking “Settings” in Sidebar
- User clicks “Settings” in the left sidebar
- Sidebar code (
app-sidebar.tsx) has this item: - Next.js routes to
/dashboard/settings/general - Layout wrapper (
layout.tsx) stays the same (sidebar still visible) - New page content loads (
settings/general/page.tsx) - Sidebar highlights “Settings” as active (via
isActiveprop)
Example: User Profile Menu
- User clicks avatar in top-right corner
- HeaderUserMenu (
header-user-menu.tsx) opens dropdown - Dropdown shows:
- Account → links to
/dashboard/settings/account - Billing → links to
/dashboard/settings/billing - Notifications → links to
/dashboard/settings/notifications - Log out → calls
supabase.auth.signOut()and redirects to/
- Account → links to
Protected Routes (How Sign-in/Sign-out Works)
The dashboard is protected by middleware that checks if you’re signed in. Location:sabo/src/lib/supabase/middleware.ts
Key arrays:
1
User visits /dashboard
Middleware checks: Is user signed in?
- Yes → Show dashboard
- No → Redirect to
/sign-in
2
User signs in successfully
Auth callback redirects to
/dashboard3
Signed-in user visits /sign-in
Middleware checks: User already signed in?
- Yes → Redirect to
/dashboard(they don’t need sign-in page) - No → Show sign-in page
Routing & Middleware
Full guide on how middleware protects routes and customizing auth guards.
How to Customize the Dashboard
1. Add a new page
Create a new file:sabo/src/app/(dashboard)/dashboard/analytics/page.tsx
/dashboard/analytics
2. Add it to sidebar navigation
Editapp-sidebar.tsx:
3. Change what’s on the main dashboard page
Editsabo/src/app/(dashboard)/dashboard/page.tsx:
Replace <SectionCards /> with your own components, or remove charts, or add new sections. This is your main dashboard page - customize it however you want.
Common Patterns
Sidebar + Top Bar Shell
Sidebar + Top Bar Shell
Settings Pages Grouped by Category
Settings Pages Grouped by Category
Settings are split into General (profile), Account (auth), Billing (payments), and Notifications (preferences). This is a common UX pattern that makes settings easy to find.
Team/Project Switcher
Team/Project Switcher
The Team Switcher at the top of the sidebar lets users switch context (e.g., between different workspaces or teams). When they switch, you’d typically update the data shown across all dashboard pages.
Data Tables and Charts
Data Tables and Charts
The main dashboard page shows metric cards at the top, charts in the middle, and data tables at the bottom. This follows the “overview → trends → details” pattern.
Troubleshooting
I'm signed in but keep getting redirected to /sign-in
I'm signed in but keep getting redirected to /sign-in
Problem: The middleware thinks you’re not signed in.Check:
- Open
sabo/src/lib/supabase/middleware.ts - Look at the
protectedRoutesarray - Make sure
/dashboardis listed:const protectedRoutes = ['/dashboard'] - Verify your session cookies are being sent (check browser DevTools → Application → Cookies)
protectedRoutes, add it.Signed-in users can still access /sign-in page
Signed-in users can still access /sign-in page
Problem: The middleware isn’t redirecting authenticated users away from auth pages.Check:
- Open
sabo/src/lib/supabase/middleware.ts - Look at the
authRoutesarray - Make sure it includes:
const authRoutes = ['/sign-in', '/sign-up']
/sign-in isn’t in authRoutes, add it. The middleware will then redirect signed-in users to /dashboard when they try to access these pages.Sidebar not showing on my dashboard page
Sidebar not showing on my dashboard page
Settings page shows but data doesn't save
Settings page shows but data doesn't save
Problem: The Supabase tables don’t exist or aren’t connected.Check:
- Do you have a
user_profilestable in Supabase? - Are the column names correct? (e.g.,
full_name,email_notifications) - Check the browser console for Supabase errors
I see double scrollbars on the dashboard
I see double scrollbars on the dashboard
Problem: Both the layout and page content have
overflow: auto.Fix:- Remove fixed heights from the layout columns
- Let the content flow naturally
- Only add
overflow-x-autoto specific components that need horizontal scroll (like wide tables)