🌐 Routing in Next.js (App Router)

πŸ“ File-based Routing

Next.js automatically creates routes based on your file structure under the app/ directory.

  • app/page.tsx β†’ / (Home route)
  • app/about/page.tsx β†’ /about
  • app/contact/page.tsx β†’ /contact

πŸ”§ Dynamic Routing

Aap dynamic parameters ke liye brackets use karte hain. For example:

  • app/blog/[slug]/page.tsx β†’ /blog/post-title
  • app/user/[id]/page.tsx β†’ /user/123

Is tarah aap dynamic routes handle kar sakte ho. Use params to access values.

πŸ”— Link Navigation

Internal routing ke liye Link component use hota hai from next/link.

βœ… Next.js App Router makes routing easy, powerful, and file-driven. You don’t need extra config β€” just create files and Next.js handles the rest!