A comprehensive Next.js 16 project demonstrating modern web development concepts, routing patterns, API integration, and best practices. This project is perfect for learning Next.js fundamentals and advanced features.
- Next.js 16.0.4 - React framework with App Router
- React 19.2.0 - UI library
- TypeScript 5 - Type-safe JavaScript
- Tailwind CSS 4 - Utility-first CSS framework
- ESLint - Code linting
- Modern file-based routing system
- Nested layouts and route groups
- Server and Client Components
- Single dynamic segments:
[post_id],[course_id],[album_id] - Multiple dynamic segments:
[...product](catch-all routes) - Nested dynamic routes with categories
(frontend)- Organizes frontend routes without affecting URL structure- Shared layouts for grouped routes
- Root layout (
app/layout.tsx) - Global layout with fonts and metadata - Route group layout (
app/(frontend)/layout.tsx) - Shared Navigation and Footer - Layout composition and nesting
- Server-side data fetching
- Async/await in Server Components
- Promise-based params handling (Next.js 16 feature)
- Server-side API calls
- Data revalidation with
next: { revalidate } - Error handling in data fetching
- TypeScript interfaces for API responses
- Separated API logic in
app/lib/api/ - Reusable API functions
- Centralized error handling
- Type-safe API calls
- Request interception
- Cookie-based authentication checks
- Route protection patterns
- Dynamic metadata configuration
- Title templates
- SEO-friendly structure
- Custom
not-found.tsxpage - Error boundaries
- API error handling
- Tailwind CSS utility classes
- Dark mode support
- Responsive design patterns
- Component-based styling
app/
βββ layout.tsx # Root layout with fonts & metadata
βββ page.tsx # Home page
βββ not-found.tsx # 404 error page
βββ globals.css # Global styles
β
βββ (frontend)/ # Route group (doesn't affect URL)
β βββ layout.tsx # Frontend layout (Navigation + Footer)
β βββ page.tsx # Home page
β β
β βββ posts/ # Posts section
β β βββ page.tsx # Posts list
β β βββ [post_id]/ # Dynamic route
β β βββ page.tsx
β β
β βββ albums/ # Albums section
β β βββ page.tsx
β β βββ [album_id]/
β β βββ page.tsx
β β
β βββ comments/ # Comments section
β β βββ page.tsx
β β βββ [comment_id]/
β β βββ page.tsx
β β
β βββ blog/ # Blog with nested routes
β β βββ page.tsx
β β βββ category/
β β βββ page.tsx
β β βββ education/
β β β βββ page.tsx
β β β βββ [blog_id]/
β β βββ sports/
β β βββ page.tsx
β β βββ [blog_id]/
β β
β βββ course/ # Course section
β β βββ page.tsx
β β βββ [course_id]/
β β βββ page.tsx
β β
β βββ shop/ # Shop with catch-all routes
β βββ page.tsx
β βββ products/
β βββ page.tsx
β βββ [...product]/ # Catch-all route
β βββ page.tsx
β
βββ Components/ # Reusable components
β βββ Navigation.tsx
β βββ Footer.tsx
β βββ RedirectClientButton.tsx
β βββ RedirectServerButton.tsx
β
βββ lib/
βββ api/ # API service layer
βββ index.ts # Central exports
βββ posts.ts
βββ albums.ts
βββ cumments.ts
middleware.ts # Request middleware
next.config.ts # Next.js configuration
- β Static routes
- β
Dynamic routes (
[id]) - β
Catch-all routes (
[...slug]) - β Nested routes
- β Route groups
- β Nested layouts
- β Server Components with async/await
- β API service layer separation
- β Data revalidation
- β Error handling
- β TypeScript type safety
- β Responsive design
- β Dark mode support
- β Navigation component
- β Footer component
- β Loading states
- β Error pages
- Node.js 18+
- npm, yarn, pnpm, or bun
# Clone the repository
git clone <your-repo-url>
cd first-nextjs-project
# Install dependencies
npm install
# Run development server
npm run devOpen http://localhost:3000 in your browser.
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintThis project is structured to help you learn Next.js concepts progressively:
- Start with: Basic routing (
app/page.tsx,app/(frontend)/page.tsx) - Learn: Dynamic routes (
[post_id],[course_id]) - Explore: Nested routes (
blog/category/education) - Understand: Layouts and route groups
- Master: API integration and data fetching
- Advanced: Middleware and route protection
Route groups allow you to organize routes without affecting the URL structure. All routes inside (frontend) share the same layout.
[id]- Single dynamic segment[...slug]- Catch-all route (matches multiple segments)
By default, all components in the App Router are Server Components. They can directly fetch data and don't send JavaScript to the client.
In Next.js 16, route params can be Promises. Always handle both Promise and direct params for compatibility:
export default async function Page({ params }: {
params: Promise<{ id: string }> | { id: string }
}) {
const resolvedParams = params instanceof Promise ? await params : params;
const id = resolvedParams.id;
// ...
}The project uses JSONPlaceholder as a mock API for:
- Posts
- Albums
- Comments
API services are separated in app/lib/api/ for better organization and reusability.
- This project uses Next.js 16 with the App Router
- All API calls are server-side (Server Components)
- TypeScript is used throughout for type safety
- Tailwind CSS 4 is used for styling
- RTL (Right-to-Left) support is configured for Persian/Farsi
This is a learning project. Feel free to:
- Fork the repository
- Experiment with different Next.js features
- Add new routes and features
- Improve documentation
DevAmir
- GitHub: @DevAmirHub
- Email: devamir99@gmail.com
I create web products with an emphasis on clean architecture, practical solutions, and long-term maintainability.
This project is open source and available for learning purposes.
Happy Learning! π