A production-ready Next.js 16 application featuring a sophisticated navigation system with role-based access control, authentication, and modern UI components. While presented as a navbar example, this project is architected as a comprehensive starting point for building scalable web applications.
- Responsive Navigation Bar with mobile and desktop variants
- Role-Based Menu System - Dynamic navigation based on user roles (user, moderator, admin)
- Priority-Based Display - Intelligent menu item visibility based on viewport size
- Theme Support - Dark/light mode with next-themes integration
- shadcn/ui Components - Beautiful, accessible UI components built with Radix UI
- Supabase Integration - Full authentication setup with SSR support
- Multi-Role System - Users can have multiple roles simultaneously
- Role-Based Routing - Different navigation routes for different user roles
- Middleware Support - Authentication middleware utilities included
- Drizzle ORM - Type-safe database access with PostgreSQL
- Schema Validation - Zod schemas for runtime validation
- User Management - Complete user schema with roles, profiles, and activity tracking
- Optimized Queries - Indexed database fields for performance
- TypeScript - Full type safety across the application
- Typed Routes - Next.js typed routes enabled for route safety
- Path Aliases - Clean imports with @ aliases
- Custom Hooks - Reusable hooks like
use-nav-routesfor role-based navigation - Organized Structure - Clear separation of concerns with config, lib, components, and hooks
- Framework: Next.js 16 (with React 19)
- Styling: Tailwind CSS 4
- UI Components: shadcn/ui (Radix UI primitives)
- Icons: Lucide React
- Database: PostgreSQL with Drizzle ORM
- Authentication: Supabase Auth
- Validation: Zod
- Type Safety: TypeScript 5
app/ # Next.js app directory
layout.tsx # Root layout with providers
page.tsx # Home page
components/
buttons/ # Reusable button components
layout/
navigation/ # Navigation components
ui/ # shadcn/ui components
config/ # Configuration files
navigation.config.ts # Route definitions by role
roles.config.ts # Role configuration
routes.config.ts # Route mappings
db/
schema.ts # Database schema
schemas/
users.schema.ts # User table definition
hooks/ # Custom React hooks
use-nav-routes.ts # Navigation route logic
lib/
actions/ # Server actions
queries/ # Database queries
services/ # Business logic
supabase/ # Supabase client configuration
types/ # TypeScript type definitions
validations/ # Zod schemas
providers/ # React context providers
- Node.js 18+
- pnpm (recommended)
- PostgreSQL database
- Supabase account
- Clone the repository:
git clone <your-repo-url>
cd navbar-example- Install dependencies:
pnpm install- Set up environment variables:
# Create a .env.local file with:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
DATABASE_URL=your_postgres_connection_string- Run database migrations:
pnpm drizzle-kit push- Start the development server:
pnpm devOpen http://localhost:3000 to view the application.
The navigation system dynamically adjusts based on user roles:
- User Role: Basic access with home dashboard
- Moderator Role: Additional moderation tools, reports, and user management
- Admin Role: Full access including analytics and system settings
Users can have multiple roles, and the navigation intelligently merges routes from all assigned roles.
Navigation items have priority levels (1-4) that control their visibility:
- md: Shows priority 1 items
- lg: Shows priority 1-2 items
- xl: Shows priority 1-3 items
- 2xl: Shows all items
Lower priority items are accessible via mobile menu on smaller screens.
The project demonstrates several architectural patterns:
- Custom Hooks: Logic extraction (e.g.,
use-nav-routes) - Server/Client Separation: Proper use of "use client" directives
- Provider Pattern: Theme and tooltip providers
- Compound Components: Navigation system with composable parts
- Update the role enum in db/schemas/users.schema.ts
- Add role configuration in config/roles.config.ts
- Define role-specific routes in config/navigation.config.ts
Edit config/navigation.config.ts and add routes to the appropriate array:
export const AUTHENTICATED_ROUTES: NavRoute[] = [
{ href: "/new-route" as Route, label: "New Feature", icon: YourIcon, priority: 1 },
];- Global styles: app/globals.css
- Theme configuration: components.json
- Tailwind config: Integrated with Tailwind CSS 4
- Production-Ready Architecture: Properly structured with separation of concerns
- Type Safety: Full TypeScript coverage with Zod validation
- Scalable Auth: Supabase integration with role-based access control
- Modern Stack: Latest Next.js, React, and Tailwind CSS versions
- Database Ready: Drizzle ORM setup with migrations and type-safe queries
- Component Library: shadcn/ui components ready to use and customize
- Best Practices: Server components, proper data fetching, and middleware patterns
pnpm dev # Start development server
pnpm build # Build for production
pnpm start # Start production server- Next.js Documentation
- Supabase Documentation
- Drizzle ORM Documentation
- shadcn/ui Documentation
- Tailwind CSS Documentation
This project is open source and available under the MIT License.