Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Next.js
Next.jseasy

How do you define a dynamic route in App Router and read params?

Tags
#routing#dynamic-route#params
Back to categoryPractice quiz

Answer

Create a folder like `app/posts/[id]/page.tsx`. In a Server Component, read it from the `params` prop; in a Client Component you can use `useParams()`.

export default function Page({ params }: { params: { id: string } }) {
  return <div>Post id: {params.id}</div>
}

Related questions

Next.js
Middleware in Next.js: what is it good for and what are its limitations?
#nextjs#middleware#edge
Next.js
Route Groups `(group)`: what are they and why use them?
#nextjs#routing#route-groups
Next.js
What are `useSearchParams()` and `useParams()` used for (and where can you use them)?
#params#search-params#hooks
Next.js
Next.js: why use `<Link>` instead of a plain `<a>` tag for internal navigation?
#nextjs#link#routing
Next.js
How do route segments and nested layouts work in Next.js?
#routing#layouts#segments