Skip to content
Learn Netverks

Lesson

Step 8/36 22% through track

dynamic-routes

Dynamic routes

Last reviewed Jun 1, 2026 Content v20260601
Track mode
client_nextjs
Means
In-browser Next.js (client components)
Reading
~2 min
Level
intermediate

This lesson

This lesson teaches Dynamic routes: the concepts, APIs, and habits you need before advancing in Next.js.

Routing maps URLs to components—guards and resolvers protect enterprise flows.

You will apply Dynamic routes in contexts like: Marketing sites, dashboards, e-commerce, and Vercel-style deployments that need hybrid static + dynamic pages.

Write TSX for Client Components, click Run—React 18 CDN + in-browser TSX compile; use client/server lessons explain App Router concepts; mountApp renders interactive UI; printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

Dynamic segments use square brackets in folder names. A folder [slug] captures one URL segment; [...slug] catches the rest (catch-all); [[...slug]] makes the catch-all optional.

Examples

app/blog/[slug]/page.tsx        → /blog/hello
app/shop/[...categories]/page.tsx → /shop/a/b/c
app/docs/[[...slug]]/page.tsx     → /docs and /docs/guide/setup

Reading params

// app/blog/[slug]/page.tsx
type Props = { params: Promise<{ slug: string }> };

export default async function BlogPost({ params }: Props) {
  const { slug } = await params;
  return <h1>Post: {slug}</h1>;
}

In Next.js 15+, params and searchParams are async Promises—await them in Server Components.

generateStaticParams

Export generateStaticParams from a dynamic page to prebuild known slugs at build time—great for blogs and product catalogs.

Important interview questions and answers

  1. Q: Difference between [slug] and [...slug]?
    A: Single segment vs one-or-more segments captured as an array.
  2. Q: How do you type dynamic params?
    A: Via the page props type; await params in async Server Components.

Self-check

  1. Which folder name handles /products/42?
  2. What does generateStaticParams enable?

Challenge

Param simulator

  1. Change the slug in the simulated params object.
  2. Print a greeting that includes the slug.
  3. Run and confirm the terminal output updates.

Done when: terminal shows your custom slug in the greeting.

Pitfall: In Next.js 15+, params is a Promise—await it in async Server Components or TypeScript will lie to you at runtime.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • [id] vs [...slug]?
  • generateStaticParams when?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump