KoderSolutionKoderSolution LogoKoderSolution Logo
HomeArticlesTutorialsToolsRun CodeForumAI Lab
▲

Next.js

Topic Hub & Articles

Next.js Intro

10 min

Next.js Installation

10 min

Next.js Routing

10 min

Next.js Pages

10 min

Next.js App Router

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Layouts

10 min

Next.js Linking and Navigating

10 min

Next.js Loading UI and Streaming

10 min

Next.js Error Handling

10 min

Next.js Data Fetching

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Server Actions

10 min

Next.js Rendering

10 min

Next.js CSS Modules

10 min

Next.js Image Optimization

10 min

Next.js Font Optimization

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Script Optimization

10 min

Next.js Static File Serving

10 min

Next.js Metadata

10 min

Next.js API Routes

10 min

Next.js Middleware

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Authentication

10 min

Next.js Deployment

10 min

Next.js Internationalization

10 min

Next.js Security

10 min

Next.js Performance

10 min

Recap Quiz

Gated

Milestone Assessment

Progress
0%

0 / 25 Lessons

KoderSolutionKoderSolution LogoKoderSolution Logo

The world’s most advanced technical ecosystem for modern software engineers. Learn, build, and grow with next-generation developer tools and resources.

Facebook PageX (Twitter) ProfileYouTube ChannelContact Support

Engineering Newsletter

Subscribe for weekly software engineering tutorials, architecture guides, and developer tool updates.

Platforms

  • Technical Articles
  • Interactive Tutorials
  • AI Coding Lab
  • Developer Forum
  • Developer Tools

Pages

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Disclaimer
  • Advertisement

Popular Topics

  • PHP
  • Laravel
  • Python
  • React.Js
  • MySQL
© 2026 KoderSolutionAll Rights Reserved
Developed Bymaksudur.dev
Next.jsNext.js Tutorial
Lesson

Next.js Routing

10 min reading
Free Course

Next.js Routing: How the App Router Maps Folders to URLs

Next.js routing uses folders inside the app/ directory to define URL paths without a central router config file. Every folder represents a URL segment, and a page.tsx file inside that folder makes the route reachable in a browser.

If a folder does not contain a page.tsx file, users cannot visit that path directly. This lets you keep helper components or styles close to a route safely.

flowchart TD
    app["app/"] --> home["page.tsx -> /"]
    app --> about["about/"]
    about --> aboutPage["page.tsx -> /about"]
    app --> blog["blog/"]
    blog --> slug["[slug]/"]
    slug --> slugPage["page.tsx -> /blog/:slug"]

Mapping Static Routes

To create a static URL like /pricing or /dashboard/settings, create matching nested folders inside app/ and add a page.tsx file to each endpoint.

File Path Browser URL
app/page.tsx /
app/pricing/page.tsx /pricing
app/dashboard/settings/page.tsx /dashboard/settings

Creating Dynamic Route Segments

Dynamic routes match changing URL values such as blog slugs, product IDs, or user handles. Wrap the folder name in square brackets, like [slug], and await params inside your async Server Component.

// app/blog/[slug]/page.tsx
interface BlogPageProps {
  params: Promise<{ slug: string }>;
}

export default async function BlogPostPage({ params }: BlogPageProps) {
  const { slug } = await params;

  return (
    <article className="max-w-3xl mx-auto p-6">
      <h2 className="text-2xl font-bold capitalize">{slug.replaceAll('-', ' ')}</h2>
      <p className="mt-3 text-gray-600">Loaded dynamic route for slug: {slug}</p>
    </article>
  );
}

Organizing Routes with Route Groups

Route groups let you split routes into logical areas without changing the public URL. Wrap a folder name in parentheses, such as (marketing) or (account), and Next.js omits that folder name from the URL path.

app/
├── (marketing)/
│   ├── layout.tsx
│   ├── about/page.tsx      -> /about
│   └── pricing/page.tsx    -> /pricing
└── (account)/
    ├── layout.tsx
    └── profile/page.tsx    -> /profile

Common Mistakes

  • Forgetting to await params in Next.js 15+: Dynamic params is a Promise in modern App Router pages, so read it with await params.
  • Naming page files after the route: Name the file page.tsx inside app/about/, not app/about.tsx.
  • Conflicting dynamic and static paths at the same level: Avoid placing two dynamic folders with different parameter names inside the same parent folder.

Frequently Asked Questions

What happens if a folder inside app/ has no page.tsx file?

The folder does not expose a public URL route. You can safely store local components, types, or test files inside it.

How do catch-all routes work in Next.js?

Use [...slug] in a folder name to match multiple nested segments, such as /docs/auth/tokens, as an array of strings.

Why use route groups instead of regular folders?

Route groups let different sections use separate layout.tsx shells while keeping clean, short public URLs.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Related Developer Tools & Topic Hub

Next.js Topic Hub
JSON Formatter
Validate and format JSON payloads
HTML Formatter
Format HTML markup
CSS Formatter
Clean and format stylesheets
All Next.js Articles
Deep-dive guides, tips & discussions
PreviousNext.js Installation
Continue JourneyNext: Next.js Pages

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum