🚀 Next.js App Router - The Complete Guide with a Hands-on Application #31
akash-coded
started this conversation in
Notes
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🚀 Next.js App Router - The Complete Guide with a Hands-on Application
📌 Overview: What We’re Building
We'll create a TCS Project Management Dashboard using the Next.js App Router. This will cover:
✅ Static and Dynamic Routing
✅ Layouts and Nested Routes
✅ Server Components vs Client Components
✅ Data Fetching (Streaming, SSG, SSR, and ISR)
✅ Middleware and Authentication
✅ Server Actions for API Calls (No API Routes Needed!)
📌 Project Structure
📌 Setting Up the Project
npx create-next-app@latest next-tcs-app-router --experimental-app cd next-tcs-app-router npm install
📌 Step 1: Creating Static Routes
🏠 1️⃣ Home Page (
/app/page.tsx
)🔹 Concepts Covered:
✅ Static routing
✅ SEO-friendly navigation
✅
Link
for client-side routingℹ️ 2️⃣ About Page (
/app/about/page.tsx
)🔹 Concepts Covered:
✅ Static page
✅ Server-first rendering
📌 Step 2: Dynamic Routing - Project Pages
🛠 3️⃣ Project List Page (
/app/projects/page.tsx
)🔹 Concepts Covered:
✅ Nested routing (
/projects/
)✅ Dynamic Links with
[id]
🆔 4️⃣ Project Details Page (
/app/projects/[id]/page.tsx
)🔹 Concepts Covered:
✅ Dynamic routing with
[id]
✅ Fetching data inside a server component (no
useEffect
needed!)📌 Step 3: Layouts and Nested Routing
🗂 5️⃣ Creating a Shared Layout (
/app/layout.tsx
)🔹 Concepts Covered:
✅ Shared layout for all pages
✅ Global state preservation
📌 Step 4: API Calls with Server Actions
🔗 6️⃣ Server Action to Fetch Projects (
/app/api/projects/route.ts
)🔹 Concepts Covered:
✅ API route replacement using Server Actions
✅ No need for
pages/api/
anymore📌 Step 5: Custom Middleware
🛡 7️⃣ Protecting Routes (
/middleware.ts
)🔹 Concepts Covered:
✅ Protecting private routes
✅ Redirecting unauthorized users
📌 Step 6: Custom 404 Page
🚨 8️⃣ Custom 404 Page (
/app/not-found.tsx
)🔹 Concepts Covered:
✅ Custom error handling
📌 Best Practices & Anti-Patterns
✅ Things to Do
✅ Use Server Components for data fetching
✅ Use Middleware for authentication and security
✅ Use Shared Layouts for consistency
✅ Optimize API calls using Server Actions
❌ Things to Avoid
❌ Do NOT use Client Components unnecessarily
❌ Do NOT fetch data in Client Components if Server Components can handle it
❌ Do NOT use
useEffect
for fetching server-side data❌ Do NOT mix Pages Router and App Router
📌 Full Code Repository
🔗 GitHub Repo: [Next.js TCS App Router](#) (Coming Soon!)
📌 Summary
✅ Static and dynamic routing
✅ Layouts and API replacements
✅ Streaming and Middleware
✅ Authentication and global state
📌 Next Steps:
🔹 Convert this into a full-fledged admin dashboard
🔹 Add protected routes and user authentication
🚀 What’s Next?
Beta Was this translation helpful? Give feedback.
All reactions