Dashboard
Protected application pages where authenticated users interact with your product.
What This System Does
The dashboard system provides:
- Automatic authentication checks for protected routes
- User dashboard for viewing account information
- Billing page for subscription management
- Plans page for upgrading subscriptions
- Foundation for building your product pages
Why It Exists
The dashboard is where users interact with your product after signing in. The protected route structure ensures only authenticated users can access these pages, and provides a foundation for building your custom features.
When You Need to Care About It
You'll work with the dashboard when:
- Building your main product features
- Adding new protected pages
- Customizing the dashboard layout or styling
- Creating feature-specific pages
Key Concepts
Protected Route Layout
All pages inside /app/(protected)/ automatically require authentication. The layout at /app/(protected)/layout.tsx calls requireAuth() and redirects unauthenticated users to /auth.
Route Groups
The (protected) folder is a Next.js route group. It doesn't affect the URL structure but groups routes that share the same layout and authentication logic.
Protected Routes
All authenticated pages live in /app/(protected)/:
/app/(protected)/layout.tsxAuth check wrapper. All pages inside inherit this check.
/app/(protected)/dashboard/page.tsxMain dashboard. This is where you build your product.
/app/(protected)/billing/page.tsxSubscription management. Shows current plan, entitlements, and upgrade options.
/app/(protected)/plans/page.tsxPlans selection page. Users can view and upgrade to different plans.
How Protection Works
// /app/(protected)/layout.tsx
export default async function ProtectedLayout({ children }) {
await requireAuth(); // Redirects to /auth if not logged in
return <div className="min-h-screen">{children}</div>;
}Important Files
/app/(protected)/layout.tsxProtected route layout. Calls requireAuth() for all child pages.
/app/(protected)/dashboard/page.tsxMain dashboard page. Build your product features here.
/components/DashboardClient.tsxClient component for dashboard. Handles interactive features.
Adding New Protected Pages
To add a new protected page:
- Create folder and page in
/app/(protected)/:text/app/(protected)/your-feature/page.tsx - The page automatically requires authentication:typescript
import { requireAuth } from "@/lib/auth-utils"; export default async function YourFeaturePage() { const user = await requireAuth(); return <div>Your feature for {user.email}</div>; }
What You Can Customize
Dashboard Page
Located at /app/(protected)/dashboard/page.tsx. This is your main product page. Build your features here.
Dashboard Layout
Modify /app/(protected)/layout.tsx to change the shared layout for all protected pages (navigation, sidebar, etc.).
Add New Protected Pages
Create new folders in /app/(protected)/ for feature-specific pages. They automatically inherit authentication protection.
What NOT to Touch
requireAuth() in Layout
The requireAuth() call in the protected layout is critical. Don't remove it or pages won't be protected.
Billing Page Core Logic
The billing page at /app/(protected)/billing/page.tsx handles subscription management. Don't modify the core subscription logic.
Related Sections
- Authentication - How protected routes work
- Entitlements - Gating features within dashboard pages
- Payments - Subscription management on billing page